/**
 * Created by ZhouWei on 2017/7/8.
 */
/**
 * Created by ZhouWei on 2017/6/24.
 */

//假数据
var obj = [];
var missObj = [];
var recommend = [];
var lotteryTime;
var min = null;
var second = null;
var isChrome = navigator.userAgent.toLowerCase().match(/chrome/) != null;
var time;
var topHengDivHeight;

function windowOnLoad() {

    $("#screenFull").show();
    setTimeout(function () {
        $("#screenFull").hide();
    },1500);

    getGameInfo();
    ajaxFunction();
    getRecommend();
    getMissing();
    if(min==null){
        getLottTime();
    }

    $(".shuzhifang table tbody").children("*").remove();

    if($(window).height()>1200){
        if (isChrome) {
            $("#header").height(0).css("display","none");
        }else{
            //$(".dataTable").css("width","1081px"); //大于 = 90期IE 竖屏 会出问题
        }
        $(".dataTable").css("fontSize","11px");
        $(".shuzhifang table").css("fontSize","11px");
    }

    dataHandle(isChrome);

    //获取准备好的tr模板
    var tr = $("#templateTable .templateTr");

    var sale = $("#templateTable .templateTrLast");

    //所有开奖号统计数组
    var statistics =[];

    var firstStatistics = [];

    var secondStatistics = [];

    var thirdStatistics = [];
    //初始化计数数组
    var tempObj = [0,0,0,0,0,0,0,0,0,0,0,0];

    var tempFirst = [0,0,0,0,0,0,0,0,0,0,0,0];

    var tempSecond = [0,0,0,0,0,0,0,0,0,0,0,0];

    var tempThird = [0,0,0,0,0,0,0,0,0,0,0,0];

    var tempGroupsDis = [0,0,0,0,0,0,0,0,0,0,0,0];

    //二维数组将所有开奖号放到statistics中
    for(var g=0;g<obj.length;g++){
        for(var d=0;d<obj[g].kaijianghao.length;d++){
            if(d == 0){
                firstStatistics.push(obj[g].kaijianghao[d]);
            }else if(d == 1){
                secondStatistics.push(obj[g].kaijianghao[d]);
            }else if(d == 2){
                thirdStatistics.push(obj[g].kaijianghao[d]);
            }
            statistics.push(obj[g].kaijianghao[d]);
        }
    }
    //tempObj用于存放统计次数 第一位的值代表1出现的次数 依次类推
    for(var c=0;c<statistics.length;c++){
        tempObj[statistics[c]-1]++;
    }

    var copyTempObj = tempObj; //冷号热号统计


    //tempFirst
    for(var c=0;c<firstStatistics.length;c++){
        tempFirst[firstStatistics[c]-1]++;
    }
    //tempSecond
    for(var c=0;c<firstStatistics.length;c++){
        tempSecond[secondStatistics[c]-1]++;
    }
    //tempThird
    for(var c=0;c<thirdStatistics.length;c++){
        tempThird[thirdStatistics[c]-1]++;
    }
    //tempThird
    for(var c=0;c<thirdStatistics.length;c++){
        tempGroupsDis[thirdStatistics[c]-1]++;
    }
    for(var c=0;c<thirdStatistics.length;c++){
        tempGroupsDis[secondStatistics[c]-1]++;
    }
    for(var c=0;c<thirdStatistics.length;c++){
        tempGroupsDis[firstStatistics[c]-1]++;
    }
    //根据传过来的数据多少创建空白行
    for(var i=0;i<obj.length+2;i++){

        $(".shuzhifang table tbody").append("<tr><td class='issueTwo'></td><th class='bd'></th></tr>");
        if(i == obj.length){   //倒计时行
            var saleClone =sale.clone();
            $(".dataTable tbody").append(saleClone);
            //填入期号
            $(".dataTable tbody tr").eq(i).children().eq(0).html(lotteryTime.next_stage);
            $(".shuzhifang table tbody tr").eq(i).find(".issueTwo").eq(0).html(lotteryTime.next_stage);

            //填入倒计时
            $(".dataTable tbody tr").eq(i).find('.countDownd').css("color","red");
            clearInterval(time);
            if(lotteryTime.text != "暂未开售"){
                time = setInterval(function(){
                    lotteryTime.n_time = lotteryTime.n_time -1;
                    min = parseInt(lotteryTime.n_time/60);
                    second = lotteryTime.n_time%60;

                    if(second<10){
                        second = "0"+second;
                    }
                    if(min<2){
                        $(".dataTable tbody tr").eq(obj.length).find('.countDownd').html("开奖中");
                    }else{
                        $(".dataTable tbody tr").eq(obj.length).find('.countDownd').html("0"+min+":"+second);
                    }

                    if(min==0 && second==0){
                        clearInterval(time);
                        $(".dataTable tbody").children("*").remove();
                        min = null;
                        windowOnLoad();
                        nextTable();
                    }
                },1000);
            }else{
                $(".dataTable tbody tr").eq(obj.length+1).find('.countDownd').html(lotteryTime.text);
            }

            //关注号码
            var a = 0;
            $(".dataTable tbody tr").eq(i).find('.attentionNum').each(function(){
                $(this).html(lotteryTime.guanzhu[a]);
                a++;
            });

        }else if(i == obj.length+1){          //统计行
            var trClone =tr.clone();
            $(".dataTable tbody").append(trClone);
            //填入0
            var v = 0;
            $(".dataTable tbody tr").eq(i).find('td').each(function(){
                $(this).html(0).css('background','#00A6A6');
                v++;
            });
            //填入总期数
            $(".dataTable tbody tr").eq(i).addClass("statisticsRow");
            $(".dataTable tbody tr").eq(i).children().eq(0).html(obj.length).css('background','#00A6A6');

            $(".shuzhifang table tbody tr").eq(i);
            $(".shuzhifang table tbody tr").eq(i).find(".issueTwo").eq(0).html(obj.length).addClass("statisticsRowLeft");
            //任选分布
            var e = 0;
            $(".dataTable tbody tr").eq(i).find('.optionalDis').each(function(){
                $(this).html(tempObj[e]).css('background','#00A6A6');
                e++;
            });
            //第一位统计
            var first=0;
            $(".dataTable tbody tr").eq(i).find('.firstCon').each(function(){
                $(this).html(tempFirst[first]).css('background','#00A6A6');
                first++;
            });
            //第二位统计
            var second=0;
            $(".dataTable tbody tr").eq(i).find('.secondCon').each(function(){
                $(this).html(tempSecond[second]).css('background','#00A6A6');
                second++;
            });
            //第三位统计
            var third=0;
            $(".dataTable tbody tr").eq(i).find('.thirdCon').each(function(){
                $(this).html(tempThird[third]).css('background','#00A6A6');
                third++;
            });
            //前三位开奖号统计
            var GroupsDis=0;
            $(".dataTable tbody tr").eq(i).find('.threeGroupsDis').each(function(){
                $(this).html(tempGroupsDis[GroupsDis]).css('background','#00A6A6');
                GroupsDis++;
            });
        }else{
            var trClone =tr.clone();
            $(".dataTable tbody").append(trClone);
            //填入期号
            obj[i].qihao = obj[i].qihao.substr(obj[i].qihao.length-2,2);
            $(".dataTable tbody tr").eq(i).children().eq(0).html(obj[i].qihao);
            $(".shuzhifang table tbody tr").eq(i).find(".issueTwo").eq(0).html(obj[i].qihao);

            //将开奖号填入表格
            var j = 0;
            $(".dataTable tbody tr").eq(i).find('.lotteryNumber').each(function(){
                var numKaijianghao = Number(obj[i].kaijianghao[j]);
                if(numKaijianghao<=9){
                    obj[i].kaijianghao[j] = obj[i].kaijianghao[j].substring(1);
                }
                $(this).html(obj[i].kaijianghao[j]);
                j++;
            });
            //任选分布
            var k = 1;
            $(".dataTable tbody tr").eq(i).find('.optionalDis').each(function(){
                for(var m=0;m<obj[i].kaijianghao.length;m++){
                    if(obj[i].kaijianghao[m] == k){
                        if(m<3){
                            $(this).addClass("optionalDisRed");
                        }else{
                            $(this).addClass("optionalDisBlue");
                        }
                        $(this).html(obj[i].kaijianghao[m]);
                    }
                }
                k++;
            });

            //任选分布遗漏
            var k=1;
            $(".dataTable tbody tr").eq(i).find('.optionalDis').each(function(){
                if(obj[i].danhaoyilou[k] !=0){
                    $(this).html(obj[i].danhaoyilou[k]);
                    $(this).addClass("missVlu");
                }
                k++;
            });

            //关注号码
            var a = 0;
            $(".dataTable tbody tr").eq(i).find('.attentionNum').each(function(){
                $(this).html(obj[i].guanzhu[a]);
                for(var num=0;num<obj[i].kaijianghao.length;num++){
                    if(obj[i].guanzhu[a] == obj[i].kaijianghao[num]){
                        $(this).addClass("attentionNumRed");
                    }
                }
                a++;
            });

            //前三位
            var j = 0;
            $(".dataTable tbody tr").eq(i).find('.threeLotteryNumber').each(function(){
                $(this).html(obj[i].kaijianghao[j]);
                j++;
            });
            //重号
            $(".dataTable tbody tr").eq(i).find('.heavyNumber').each(function(){
                $(this).html(obj[i].chonghao);
            });
/*            //前三和值的大小
            $(".dataTable tbody tr").eq(i).find('.firstThreeValuesBs').each(function(){
                if(obj[i].hezhidaxiao == "大"){
                    $(".dataTable tbody tr").eq(i).find('.firstThreeValuesBs').eq(0).html(obj[i].hezhidaxiao);
                }else if(obj[i].hezhidaxiao == "小"){
                    $(".dataTable tbody tr").eq(i).find('.firstThreeValuesBs').eq(2).html(obj[i].hezhidaxiao);
                }else{
                    $(".dataTable tbody tr").eq(i).find('.firstThreeValuesBs').eq(1).html(obj[i].hezhidaxiao);
                }
            });*/
            //前三和值
            $(".dataTable tbody tr").eq(i).find('.firstThreeValues').each(function(){
                $(this).html(obj[i].qiansanhezhi);
            });
/*            //和值单双
            $(".dataTable tbody tr").eq(i).find('.andValueSd').each(function(){
                if(obj[i].hezhijiou == "单"){
                    $(".dataTable tbody tr").eq(i).find('.andValueSd').eq(0).html(obj[i].hezhijiou);
                }else{
                    $(".dataTable tbody tr").eq(i).find('.andValueSd').eq(1).html(obj[i].hezhijiou);
                }
            });*/
            //总的和值
            $(".dataTable tbody tr").eq(i).find('.andValueAll').each(function(){
                $(this).html(obj[i].hezhi);
            });
            //前重
            $(".dataTable tbody tr").eq(i).find('.theFormer').each(function(){
                $(this).html(obj[i].qiansanchonghao);
            });
            //奇数
            $(".dataTable tbody tr").eq(i).find('.Odd').each(function(){
                $(this).html(obj[i].jishu);
            });
            //大数
            $(".dataTable tbody tr").eq(i).find('.bigNum').each(function(){
                $(this).html(obj[i].dashu);
            });
            //前三组分布
            var k = 1;
            $(".dataTable tbody tr").eq(i).find('.threeGroupsDis').each(function(){
                for(var m=0;m<3;m++){
                    if(obj[i].kaijianghao[m] == k){
                        $(this).html(obj[i].kaijianghao[m]);
                    }
                }
                k++;
            });
            //跨度
            $(".dataTable tbody tr").eq(i).find('.spanDataTable').each(function(){
                $(this).html(obj[i].kuadu);
            });
            //前跨
            $(".dataTable tbody tr").eq(i).find('.beforeCross').each(function(){
                $(this).html(obj[i].qiankua);
            });
        }
    }

    if($(window).height()>1200){
        if (isChrome) {
            $(".optionalDisRed").css("background-size","16px 18px");
            $(".optionalDisBlue").css("background-size","16px 18px");
        }else{
            $(".optionalDisRed").css("background-size","16px 16px");
            $(".optionalDisBlue").css("background-size","16px 16px");
        }
        $(".shuzhifang table tr td").css("fontSize","11px");
    }

    topHengDivHeight = $("#topHengDiv").height();

    $(".issue").remove();
    $(".dataTable .templateTrLast td").eq(0).remove();
    $("#qihao table tr th").height(topHengDivHeight-3+"px");
    svg(svgObj);
    nextTable();

}
$(function(){
    windowOnLoad();
    var myBox = document.getElementById('main');
    var startX= 0;
    var startY = 0;
    var direction;
    var slider = {
        //判断设备是否支持touch事件
        touch:('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch,
        slider:document.getElementById('main'),

        //事件
        events:{
            index:0,     //显示元素的索引
            slider:myBox,     //this为slider对象
            handleEvent:function(event){
                var self = this;     //this指events对象
                if(event.type == 'touchstart'){
                    self.start(event);
                }else if(event.type == 'touchmove'){
                    self.move(event);
                }else if(event.type == 'touchend'){
                    self.end(event);
                }
            },
            //滑动开始
            start:function(event){
                var touch = event.targetTouches[0];     //touches数组对象获得屏幕上所有的touch，取第一个touch
                startPos = {x:touch.pageX,y:touch.pageY,time:+new Date};    //取第一个touch的坐标值
                isScrolling = 0;   //这个参数判断是垂直滚动还是水平滚动
                myBox.addEventListener('touchmove',this,false);
                myBox.addEventListener('touchend',this,false);
            },
            //移动
            move:function(event){
                //当屏幕有多个touch或者页面被缩放过，就不执行move操作
                if(event.targetTouches.length > 1 || event.scale && event.scale !== 1) return;
                var touch = event.targetTouches[0];
                endPos = {x:touch.pageX - startPos.x,y:touch.pageY - startPos.y};
                isScrolling = Math.abs(endPos.x) < Math.abs(endPos.y) ? 1:0;    //isScrolling为1时，表示纵向滑动，0为横向滑动
                if(isScrolling === 0){
                    if(direction != "top"){
                        direction = "left";
                        $("#zhuti .dataTable").css('transform', 'translate(' + (startX +endPos.x) + 'px,'+startY+'px) translateZ(0px)');
                        $("#topHengDiv table").css('transform', 'translate(' + (startX +endPos.x) + 'px,0px) translateZ(0px)');
                        $("#svg").css('transform', 'translate(' + (startX +endPos.x) + 'px,'+startY+'px) translateZ(0px)');
                    }
                }else{
                    if(direction != "left"){
                        direction = "top";
                        $("#zhuti .dataTable").css('transform', 'translate('+startX+'px,' + (startY +endPos.y) + 'px) translateZ(0px)');
                        $(".shuzhifang table").css('transform', 'translate(0px,' + (startY +endPos.y) + 'px) translateZ(0px)');
                        $("#svg").css('transform', 'translate('+startX+'px,' + (startY +endPos.y) + 'px) translateZ(0px)');
                    }
                }
                event.preventDefault();
            },
            //滑动释放
            end:function(event){
                var duration = +new Date - startPos.time;    //滑动的持续时间
                if(direction == "left"){
                    startX = startX +endPos.x;
                }else{
                    startY = startY +endPos.y;
                }
                direction = null;
                if($("#zhuti .dataTable").offset().left>20){
                    startX = 0;
                    endPos.x = 0;
                    $("#zhuti .dataTable").css('transform', 'translate(' + (startX) + 'px,'+startY+'px) translateZ(0px)');
                    $("#topHengDiv table").css('transform', 'translate(' + (startX) + 'px,0px) translateZ(0px)');
                    $("#svg").css('transform', 'translate(' + (startX) + 'px,0px) translateZ(0px)');
                }
                if($("#zhuti .dataTable").offset().top>30+topHengDivHeight){
                    startY =0;
                    endPos.y = 0;
                    $("#zhuti .dataTable").css('transform', 'translate('+startX+'px,' + (startY +endPos.y) + 'px) translateZ(0px)');
                    $(".shuzhifang table").css('transform', 'translate(0px,' + (startY +endPos.y) + 'px) translateZ(0px)');
                    $("#svg").css('transform', 'translate('+startX+'px,' + (startY +endPos.y) + 'px) translateZ(0px)');
                }

                var yyy = $("#main").height() - $(".dataTable").height() - topHengDivHeight;
                if(startY < yyy){
                    startY =yyy;
                    $("#zhuti .dataTable").css('transform', 'translate('+startX+'px,' + (yyy) + 'px) translateZ(0px)');
                    $(".shuzhifang table").css('transform', 'translate(0px,' + (yyy) + 'px) translateZ(0px)');
                    $("#svg").css('transform', 'translate('+startX+'px,' + (yyy) + 'px) translateZ(0px)');
                }
                var xxx = $("#main").width() - $(".dataTable").width() - 20;
                if(startX < xxx){
                    startX =xxx;
                    $("#zhuti .dataTable").css('transform', 'translate(' + (startX) + 'px,'+startY+'px) translateZ(0px)');
                    $("#topHengDiv table").css('transform', 'translate(' + (startX) + 'px,0px) translateZ(0px)');
                    $("#svg").css('transform', 'translate(' + (startX) + 'px,'+startY+'px) translateZ(0px)');
                }
                //解绑事件
                myBox.removeEventListener('touchmove',this,false);
                myBox.removeEventListener('touchend',this,false);
            }
        },
        //初始化
        init:function(){
            var self = this;     //this指slider对象
            if(!!self.touch) self.slider.addEventListener('touchstart',self.events,false);    //addEventListener第二个参数可以传一个对象，会调用该对象的handleEvent属性
        }
    };
    slider.init();
    /*   $(".main").scroll(function(){
     var left = $(".main").scrollLeft();
     var top = $(".main").scrollTop();
     if(top){
     /!*            $(".dataTableThead>div").css("position","fixed");
     if(top >=30){
     $(".dataTableThead>div").css("top","0");
     }else{
     if($(window).height()>1500){
     if (isChrome) {
     $(".dataTableThead>div").css("top","0");
     }else{
     $(".dataTableThead>div").css("top",30-top+"px");
     }
     }else{
     $(".dataTableThead>div").css("top",30-top+"px");
     }
     }*!/
     /!*           if(left){
     $(".TheadDiv").css("marginTop",top);
     $("#svg").css("marginTop",top);
     $(".TheadDiv").css("position","static").css("zIndex",10000);
     }else{
     $(".TheadDiv").css("marginTop",0);
     $(".TheadDiv").css("position","fixed");
     }*!/
     //$(".TheadDiv").attr("transform","translateY("+(0)+")");
     /!*            if(left){
     $(".dataTableThead").hide();
     $(".dataTable thead").show();
     }else{
     $(".dataTableThead").show();
     $(".dataTable thead").hide();
     }*!/
     $(".issueTwo").eq(0).css("top",-top+76);
     }
     if(left){
     /!*            if(top){
     $(".dataTableThead").show();
     $(".dataTable thead").hide();
     }else{
     $(".dataTableThead").hide();
     $(".dataTable thead").show();
     }*!/
     //$(".qihaoTTT").css("top","30px").css("left",0);
     $(".issueTwo").css("position","fixed");
     $(".TheadDiv").css("left",-left);
     //$(".dataTable tbody").css("left",-left);
     //alert(document.getElementsByClassName("TheadDiv"))
     //document.getElementsByClassName("TheadDiv")[0].style.transition = "-webkit-transform 0ms";
     //document.getElementsByClassName("TheadDiv")[0].style.webkitTransform="translateX("+(-left)+"px"+") scale(1) translateZ(0px)";
     //$(".TheadDiv").attr("transform","translateX("+(-left)+")");
     //transform:translateX(10px);
     //$(".dataTableThead>div").css("position","static");
     }
     //$(".dataTableThead>div").css("left",-left+"px");
     });*/
});

/*$(window).resize(function() {
 if($(window).height()>1500){

 }
 });*/

function dataHandle(isChrome) {
    var winHeight = $(window).height();
    if($(window).width()<1050){
        $(".main").height(winHeight - 181);
        $(".dataTable").height(winHeight - 181);
        $(".shuzhifang table").height(winHeight - 181);
    }else{
        if (isChrome) {
            if($(window).height()>1500){
                $(".dataTable").height(winHeight - 202 - $("#topHengDiv").height());
                $(".shuzhifang table").height(winHeight - 202 - $("#topHengDiv").height());
            }else{
                $(".dataTable").height(winHeight - 233 -$("#topHengDiv").height());
                $(".shuzhifang table").height(winHeight - 233 - $("#topHengDiv").height());
            }
        }else{
            $(".dataTable").height(winHeight - 233 - $("#topHengDiv").height());
            $(".shuzhifang table").height(winHeight - 233 - $("#topHengDiv").height());
        }
    }
}

//坐标存放数组
var coordinateRectF=[];
var coordinateRectS=[];
var coordinateRectT=[];
var coordinateRectTails=[];    //前三和尾连线
var coordinateRectFormer=[];  //前重连线
var coordinateRectHeavy = []; //重号连线
var coordinateRectSpan = []; //跨度连线
var coordinateRectCross = []; //前跨连线

var svgObj = [
    {
        fontColor:"black",
        bgColor:"#F0FFF8"
    },{
        fontColor:"black",
        bgColor:"#F0FFF8"
    },{
        fontColor:"black",
        bgColor:"#F0FFF8"
    },{
        fontColor:"black",
        bgColor:"#F0FFF8"
    },{
        fontColor:"black",
        bgColor:"#F0FFF8"
    },{
        fontColor:"black",
        bgColor:"#F0FFF8"
    }
    ,{
        lineColor:"black"
    }
];

function svg(svgObj){

    var height = $('.dataTable').height();
    var width = $('.dataTable').width();
    var he = $(".dataTable tbody tr").eq(0).height()/2;
    var wi = $(".dataTable tbody tr").eq(0).find(".lotteryNumber").eq(0).width()/2;
    var arraySvgF = [];
    var arraySvgS = [];
    var arraySvgT = [];
    var arraySvgTails = [];
    var arraySvgFormer = [];
    var arraySvgHeavy = [];
    var arraySvgSpan = [];
    var arraySvgCross = [];

    coordinateRectF=[];
    coordinateRectS=[];
    coordinateRectT=[];
    coordinateRectTails=[];    //前三和尾连线
    coordinateRectFormer=[];  //前重连线
    coordinateRectHeavy = []; //重号连线
    coordinateRectSpan = []; //跨度连线
    coordinateRectCross = []; //前跨连线


    var allCoordinateRect = [];

    for(var i=0;i<obj.length;i++){
        if($(".firstCon").css("display") != "none"){
            //第一位连线
            var firstCon = $(".dataTable tbody tr").eq(i).find('.firstCon');
            var top = firstCon.eq(obj[i].kaijianghao[0]-1).position().top;
            var left = firstCon.eq(obj[i].kaijianghao[0]-1).position().left;
            var rectF = {
                top:top,
                left:left,
                val:obj[i].kaijianghao[0]
            };
            coordinateRectF.push(rectF);


            //第二位连线
            var secondCon = $(".dataTable tbody tr").eq(i).find('.secondCon');
            var topS = secondCon.eq(obj[i].kaijianghao[1]-1).position().top;
            var leftS = secondCon.eq(obj[i].kaijianghao[1]-1).position().left;
            var rectS = {
                top:topS,
                left:leftS,
                val:obj[i].kaijianghao[1]
            };
            coordinateRectS.push(rectS);

            //第三位连线
            var thirdCon = $(".dataTable tbody tr").eq(i).find('.thirdCon');
            var topT = thirdCon.eq(obj[i].kaijianghao[2]-1).position().top;
            var leftT = thirdCon.eq(obj[i].kaijianghao[2]-1).position().left;
            var rectT = {
                top:topT,
                left:leftT,
                val:obj[i].kaijianghao[2]
            };
            coordinateRectT.push(rectT);
        }
        if($(".firstThreeTails").css("display") != "none"){
            //前三和尾连线
            var firstThreeTails = $(".dataTable tbody tr").eq(i).find('.firstThreeTails');
            var topTails = firstThreeTails.eq(obj[i].qiansanhewei).position().top;
            var leftTails = firstThreeTails.eq(obj[i].qiansanhewei).position().left;
            var rectTails = {
                top:topTails,
                left:leftTails,
                val:obj[i].qiansanhewei
            };
            coordinateRectTails.push(rectTails);
        }
        if($(".theFormerLine").css("display") != "none"){
            //前重连线
            var theFormer = $(".dataTable tbody tr").eq(i).find('.theFormerLine');
            var topFormer = theFormer.eq(obj[i].qiansanchonghao).position().top;
            var leftFormer = theFormer.eq(obj[i].qiansanchonghao).position().left;
            var rectFormer = {
                top:topFormer,
                left:leftFormer,
                val:obj[i].qiansanchonghao
            };
            coordinateRectFormer.push(rectFormer);
        }
        if($(".heavyNumberLine").css("display") != "none"){
            //重号连线
            var heavyNumberLine = $(".dataTable tbody tr").eq(i).find('.heavyNumberLine');
            var topHeavy = heavyNumberLine.eq(obj[i].chonghao).position().top;
            var leftHeavy = heavyNumberLine.eq(obj[i].chonghao).position().left;
            var rectHeavy = {
                top:topHeavy,
                left:leftHeavy,
                val:obj[i].chonghao
            };
            coordinateRectHeavy.push(rectHeavy);
        }
        if($(".spanDataTableLine").css("display") != "none"){
            var spanDataTableLine = $(".dataTable tbody tr").eq(i).find('.spanDataTableLine');
            var topSpan = spanDataTableLine.eq(obj[i].kuadu-4).position().top;
            var leftSpan = spanDataTableLine.eq(obj[i].kuadu-4).position().left;
            var rectSpan = {
                top:topSpan,
                left:leftSpan,
                val:obj[i].kuadu
            };
            coordinateRectSpan.push(rectSpan);
        }//跨度标点
        if($(".beforeCrossLine").css("display") != "none"){
            var beforeCrossLine = $(".dataTable tbody tr").eq(i).find('.beforeCrossLine');
            var topCross = beforeCrossLine.eq(obj[i].qiankua-2).position().top;
            var leftCross = beforeCrossLine.eq(obj[i].qiankua-2).position().left;
            var rectCross = {
                top:topCross,
                left:leftCross,
                val:obj[i].qiankua
            };
            coordinateRectCross.push(rectCross);
        }//前跨标点
    }

    if($("#svg")){
        $("#svg").remove();
    }
    var svg = $("<svg id='svg' version='1.1' xmlns='http://www.w3.org/2000/svg'></svg>");
    svg.attr("height",height+topHengDivHeight-46).attr('width',width)/*.css("position","absolute").css("left","0").css("top",topHengDivHeight-46)*/;
    $("#zhuti").append(svg);

    //画线
    var lineWidth = 1;
    var size = 22;
    var xxx = 1;
    var yyy = 8;
    var w = 0;
    var h = 0;
    if($(window).width()<1000){
        /*        size = 10;
         xxx =0;
         wi = $(".dataTable tbody tr").eq(0).find(".lotteryNumber").eq(0).width()/2+2;
         yyy = 5;
         lineWidth = 0.3;
         w = 1;*/
    }

    if($(window).height()>1200){
        size = 16;
        xxx =1;
        wi = $(".dataTable tbody tr").eq(0).find(".lotteryNumber").eq(0).width()/2;
        yyy = 6;
        lineWidth = 0.5;
        w = 0;
    }

    if($(".firstCon").css("display") != "none"){
        for (var q=0;q<coordinateRectF.length;q++){
            coordinateRectF[q].left = coordinateRectF[q].left+wi;
            coordinateRectF[q].top = coordinateRectF[q].top+he;
        }
        for (var u=0;u<coordinateRectF.length;u++){
            arraySvgF.push(coordinateRectF[u].left+","+coordinateRectF[u].top);
        }

        var firstLine = document.createElementNS("http://www.w3.org/2000/svg", "polyline");
        firstLine.setAttribute("fill", "none");
        firstLine.setAttribute("points", arraySvgF);
        firstLine.setAttribute("stroke", svgObj[6].lineColor);
        firstLine.setAttribute("stroke-width", lineWidth);
        svg.append(firstLine);


        for (var q=0;q<coordinateRectS.length;q++){
            coordinateRectS[q].left = coordinateRectS[q].left+wi;
            coordinateRectS[q].top = coordinateRectS[q].top+he;
        }
        for (var u=0;u<coordinateRectS.length;u++){
            arraySvgS.push(coordinateRectS[u].left+","+coordinateRectS[u].top);
        }

        var secondLine = document.createElementNS("http://www.w3.org/2000/svg", "polyline");
        secondLine.setAttribute("fill", "none");
        secondLine.setAttribute("points", arraySvgS);
        secondLine.setAttribute("stroke",svgObj[6].lineColor);
        secondLine.setAttribute("stroke-width", lineWidth);
        svg.append(secondLine);

        for (var q=0;q<coordinateRectT.length;q++){
            coordinateRectT[q].left = coordinateRectT[q].left+wi;
            coordinateRectT[q].top = coordinateRectT[q].top+he;
        }
        for (var u=0;u<coordinateRectT.length;u++){
            arraySvgT.push(coordinateRectT[u].left+","+coordinateRectT[u].top);
        }

        var thirdLine = document.createElementNS("http://www.w3.org/2000/svg", "polyline");
        thirdLine.setAttribute("fill", "none");
        thirdLine.setAttribute("points", arraySvgT);
        thirdLine.setAttribute("stroke", svgObj[6].lineColor);
        thirdLine.setAttribute("stroke-width", lineWidth);
        svg.append(thirdLine);

        allCoordinateRect.push(coordinateRectF);
        allCoordinateRect.push(coordinateRectS);
        allCoordinateRect.push(coordinateRectT);

    }

    if($(".firstThreeTails").css("display") != "none"){
        for (var q=0;q<coordinateRectTails.length;q++){
            coordinateRectTails[q].left = coordinateRectTails[q].left+wi;
            coordinateRectTails[q].top = coordinateRectTails[q].top+he;
        }
        for (var u=0;u<coordinateRectTails.length;u++){
            arraySvgTails.push(coordinateRectTails[u].left+","+coordinateRectTails[u].top);
        }

        var tailsLine = document.createElementNS("http://www.w3.org/2000/svg", "polyline");
        tailsLine.setAttribute("fill", "none");
        tailsLine.setAttribute("points", arraySvgTails);
        tailsLine.setAttribute("stroke", svgObj[6].lineColor);
        tailsLine.setAttribute("stroke-width", lineWidth);
        svg.append(tailsLine);
        allCoordinateRect.push(coordinateRectTails);
    }

    if($(".theFormerLine").css("display") != "none"){
        //前重连线
        for (var q=0;q<coordinateRectFormer.length;q++){
            coordinateRectFormer[q].left = coordinateRectFormer[q].left+wi;
            coordinateRectFormer[q].top = coordinateRectFormer[q].top+he;
        }
        for (var u=0;u<coordinateRectFormer.length;u++){
            arraySvgFormer.push(coordinateRectFormer[u].left+","+coordinateRectFormer[u].top);
        }

        var FormerLine = document.createElementNS("http://www.w3.org/2000/svg", "polyline");
        FormerLine.setAttribute("fill", "none");
        FormerLine.setAttribute("points", arraySvgFormer);
        FormerLine.setAttribute("stroke", svgObj[6].lineColor);
        FormerLine.setAttribute("stroke-width", lineWidth);
        svg.append(FormerLine);
        allCoordinateRect.push(coordinateRectFormer);
    }

    if($(".heavyNumberLine").css("display") != "none"){
        //重号连线
        for (var q=0;q<coordinateRectHeavy.length;q++){
            coordinateRectHeavy[q].left = coordinateRectHeavy[q].left+wi;
            coordinateRectHeavy[q].top = coordinateRectHeavy[q].top+he;
        }
        for (var u=0;u<coordinateRectHeavy.length;u++){
            arraySvgHeavy.push(coordinateRectHeavy[u].left+","+coordinateRectHeavy[u].top);
        }

        var HeavyLine = document.createElementNS("http://www.w3.org/2000/svg", "polyline");
        HeavyLine.setAttribute("fill", "none");
        HeavyLine.setAttribute("points", arraySvgHeavy);
        HeavyLine.setAttribute("stroke", svgObj[6].lineColor);
        HeavyLine.setAttribute("stroke-width", lineWidth);
        svg.append(HeavyLine);
        allCoordinateRect.push(coordinateRectHeavy);
    }

    if($(".spanDataTableLine").css("display") != "none"){
        //跨度连线
        for (var q=0;q<coordinateRectSpan.length;q++){
            coordinateRectSpan[q].left = coordinateRectSpan[q].left+wi;
            coordinateRectSpan[q].top = coordinateRectSpan[q].top+he;
        }
        for (var u=0;u<coordinateRectSpan.length;u++){
            arraySvgSpan.push(coordinateRectSpan[u].left+","+coordinateRectSpan[u].top);
        }

        var spanLine = document.createElementNS("http://www.w3.org/2000/svg", "polyline");
        spanLine.setAttribute("fill", "none");
        spanLine.setAttribute("points", arraySvgSpan);
        spanLine.setAttribute("stroke", svgObj[6].lineColor);
        spanLine.setAttribute("stroke-width", lineWidth);
        svg.append(spanLine);
        allCoordinateRect.push(coordinateRectSpan);
    }

    if($(".beforeCrossLine").css("display") != "none"){
        //前跨连线
        for (var q=0;q<coordinateRectCross.length;q++){
            coordinateRectCross[q].left = coordinateRectCross[q].left+wi;
            coordinateRectCross[q].top = coordinateRectCross[q].top+he;
        }
        for (var u=0;u<coordinateRectCross.length;u++){
            arraySvgCross.push(coordinateRectCross[u].left+","+coordinateRectCross[u].top);
        }

        var CrossLine = document.createElementNS("http://www.w3.org/2000/svg", "polyline");
        CrossLine.setAttribute("fill", "none");
        CrossLine.setAttribute("points", arraySvgCross);
        CrossLine.setAttribute("stroke", svgObj[6].lineColor);
        CrossLine.setAttribute("stroke-width", lineWidth);
        svg.append(CrossLine);
        allCoordinateRect.push(coordinateRectCross);
    }

    var indexOne,indexTwo,indexThree,indexFour,indexFive,indexSix;

    indexOne = allCoordinateRect.indexOf(coordinateRectF);

    indexTwo = allCoordinateRect.indexOf(coordinateRectTails);

    indexThree = allCoordinateRect.indexOf(coordinateRectFormer);

    indexFour = allCoordinateRect.indexOf(coordinateRectHeavy);

    indexFive = allCoordinateRect.indexOf(coordinateRectSpan);

    indexSix = allCoordinateRect.indexOf(coordinateRectCross);

    var color;
    var fontColor;
    if(!fontFamily){
        fontFamily = "IskoolaPota"
    }
    for(var p=0;p<allCoordinateRect.length;p++){
        if(p == indexTwo){
            color = svgObj[1].bgColor;
            fontColor = svgObj[1].fontColor;
        }else if(p == indexThree){
            color = svgObj[2].bgColor;
            fontColor = svgObj[2].fontColor;
        }else if(p == indexFour){
            color = svgObj[3].bgColor;
            fontColor = svgObj[3].fontColor;
        }else if(p == indexFive){
            color = svgObj[4].bgColor;
            fontColor = svgObj[4].fontColor;
        }else if(p == indexSix){
            color = svgObj[5].bgColor;
            fontColor = svgObj[5].fontColor;
        }else if(indexOne>-1){
            if(p == indexOne || p==indexOne+1 || p==indexOne+2){
                color = svgObj[0].bgColor;
                fontColor = svgObj[0].fontColor;
            }
        }else{
            break;
        }

        for(var y=0;y<allCoordinateRect[p].length;y++){
            var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
            var text = document.createElementNS("http://www.w3.org/2000/svg", "text");
            $(rect).attr("x", allCoordinateRect[p][y].left-wi+wi*3/5-w).attr("y",allCoordinateRect[p][y].top-he+he*1/5-h).attr("width",wi*6/5).attr("height",he*8/5);
            $(rect).attr("fill",color);
            $(text).attr("x", allCoordinateRect[p][y].left+xxx).attr("y",allCoordinateRect[p][y].top+yyy);
            $(text).attr("text-anchor","middle").text(allCoordinateRect[p][y].val);
            $(text).attr("font-size",size).attr("letter-spacing","-1").attr("font-family",fontFamily).attr("fill",fontColor);
            svg.append(rect);
            svg.append(text);
        }
    }
}

function nextTable() {
    var bottomTable = $("#bottomTable tbody tr");
    var tr = bottomTable.length;

    if(typeof recommend[1][1] == "string"){
        for(var q=0;q<recommend.length;q++){
            recommend[q][1]  = recommend[q][1].split(",");
            recommend[q][4]  = recommend[q][4].split(",");
        }
    }

    for(var i=0;i<8;i++){

        if(i%2 ==0) {
            $("#bottomTable tbody tr").eq(i).css("background","#F1F1D6");
        }else{
            $("#bottomTable tbody tr").eq(i).css("background","#DBECC7");
        }
        var name = i==0 ? ".flagOne" : i==1 ? ".flagTwo" : i==2 ? ".flagThree" :i==3 ? ".flagFour" :i==4 ? ".flagFive"
            :i==5 ? ".flagSix" : i == 6 ? ".flagSeven" : i==7 ? ".flagEight" : ".flagOne";
        var k = 0;
        $("#bottomTable tbody tr").find(name).each(function () {
            if(k == 0){
                $(this).html(missObj[i].号码);
            }else if (k==1){
                $(this).html(missObj[i].当前遗漏);
            }else if (k==2){
                $(this).html(missObj[i].上次遗漏);
            }else{
                $(this).html(missObj[i].历史遗漏);
            }
            k++;
        });
    }

    for(var j=0;j<$("#groomNum tbody tr").length;j++){
        var k=0;
        var r=0;
        var g =0;
        $("#groomNum tbody tr").eq(j).find("td").each(function(){
            if(k==1 || k==2 || k==3){
                if(recommend[j][1][r].indexOf("√")>-1){
                    $(this).css("color","red");
                }
                $(this).html(recommend[j][1][r]);
                r++;
            }else if(k ==6 || k==7 || k==8){
                if(recommend[j][4][g].indexOf("√")>-1){
                    $(this).css("color","red");
                }
                $(this).html(recommend[j][4][g]);
                g++;
            }else if(k ==4 || k==5){
                $(this).html(recommend[j][k-2]);
            }else if(k==9){
                $(this).html(recommend[j][k-4]);
            }else{
                $(this).html(recommend[j][k]);
            }
            k++
        })
    }
}

function canvasF(allCoordinateRect){


    var he = $(".dataTable tbody tr").eq(0).height()/2;
    var wi = $(".dataTable tbody tr").eq(0).find(".firstCon").eq(0).width()/2;
    var widthLattice = 14;
    var heightLattice = 20;
    var deviationRow = 4;
    var deviationCol = 10;
    var tag = 8;
    var maxW = 12;

    var height = $('.dataTable').height();
    var width = $('.dataTable').width();
    var canvas = $("<canvas id='canvas'></canvas>");
    canvas.attr("height",height).attr('width',width);

    $(".main").append(canvas);

    var oC = document.getElementById('canvas');
    var oGC = oC.getContext('2d');
    oGC.lineWidth=1;
    oGC.font = "20px iskoola Pota";
    oGC.strokeStyle = "black";
    oGC.textAlign="center";

    if($(window).height()>1200){
        oGC.font = "14px iskoola Pota";
        widthLattice = 15;
        heightLattice = 15;
        deviationRow = 3;
        deviationCol = 7;
        oGC.lineWidth=1;
    }
    if($(window).width()<1000){
        oGC.font = "5px iskoola Pota";
        widthLattice = 2*wi;
        heightLattice = 2*he-4;
        deviationRow = 1;
        deviationCol = he-2;
        tag = 4;
        maxW = 8;
        oGC.lineWidth=1;
    }

    for(var can=0;can<allCoordinateRect.length;can++){
        oGC.beginPath();
        oGC.moveTo(allCoordinateRect[can][0].left+wi+0.5,allCoordinateRect[can][0].top+he+0.5);
        for(var o=1;o<allCoordinateRect[can].length;o++){
            oGC.lineTo(allCoordinateRect[can][o].left+wi+0.5,allCoordinateRect[can][o].top+he+0.5);
        }
        oGC.stroke();
        oGC.closePath();
    }

    /*    for(var rec=0;rec<allCoordinateRect.length;rec++){
     if(rec == 0){
     oGC.fillStyle='#F0FFF8';
     }else if (rec ==1){
     oGC.fillStyle='#F0FFF8';
     }else{
     oGC.fillStyle='#EFF9EE';
     }
     for(var oo=0;oo<allCoordinateRect[rec].length;oo++){
     oGC.fillRect(allCoordinateRect[rec][oo].left+deviationRow,allCoordinateRect[rec][oo].top+he-deviationCol,widthLattice,heightLattice);
     oGC.strokeText(allCoordinateRect[rec][oo].val,allCoordinateRect[rec][oo].left+wi+2,allCoordinateRect[rec][oo].top+he+tag,maxW);
     }
     }*/
}

//任选四， 加倍弹出选项
$(".sphereFun>div>i").click(function(){
    if($(this).siblings(".choicePm").css("display") == "none"){
        $(this).siblings(".choicePm").show();
    }else{
        $(this).siblings(".choicePm").hide();
    }
});

var choiceNum = [];
var bgRed = "radial-gradient(circle at 45px 25px, #ffb5b5,#ae0000)";
var bgGray = "radial-gradient(circle at 45px 25px, #F0F0F0,#7B7B7B)";
if($(window).width()<1079){
    bgGray = "radial-gradient(circle at 20px 10px, #F0F0F0,#7B7B7B)";
    bgRed = "radial-gradient(circle at 20px 10px, #ffb5b5,#ae0000)";
}
var methodArray = ["任选一中一","任选二中二","任选三中三","任选四中四","任选五中五",
    "任选六中五","任选七中五","任选八中五","选前一直选","选前二直选","选前二组选","选前三直选","选前三组选"];
var objThree = {
    hundreds: "",
    decade: "",
    unit: ""
};

//选择一个任选选项 加倍 改变界面
$(".sphereFun>div").each(function () {
    $(this).find(".choicePm ul li").click(function(){
        var x = $(this).parent().parent().parent().index();
        if(x == 0){
            var method = $(".sphereFun>div").eq(0).find("label").html();
            $(".circle").css("background",bgGray);
            if($.inArray(method,methodArray)>=8){   //如果是组选或者直选  将这个对象清空
                objThree.hundreds = "";
                objThree.decade = "";
                objThree.unit = "";
            }else{                                           //清空数组
                choiceNum = [];
            }
            if($(this).index() >= 8){
                $(".positionNum label").css("display","none");
                if($(this).index() == 8){
                    $(".positionNum span").css("backgroundColor","#D4D2D5");
                    $(".positionNum span").eq(2).css("backgroundColor","#119F99");
                }else if($(this).index()>8 && $(this).index()<11){
                    $(".positionNum span").css("backgroundColor","#D4D2D5");
                    $(".positionNum span").eq(1).css("backgroundColor","#119F99");
                }else{
                    $(".positionNum span").css("backgroundColor","#D4D2D5");
                    $(".positionNum span").eq(0).css("backgroundColor","#119F99");
                }
            }else{
                $(".positionNum label").css("display","block");
            }
            $(this).parent().parent().css("display","none").siblings("label").html($(this).html());

        }else if(x == 1){
            if($(this).index() == 0){//自定义
                $(".modalBox").css("display","block");
                $(this).parent().parent().css("display","none");
            }else{
                if($(window).width()<1000){
                    $(".sphereFun>div").eq(1).find("label").css("fontSize","9px");
                }
                $(this).parent().parent().css("display","none").siblings("label").html($(this).html()).attr("value",$(this).attr("value"));
            }
        }
    });
});

//自定义倍数点击确定或者取消
$(".modalBox>div>span").click(function(){
    var ex = /^\d+$/;  //判断整数
    if($(this).html() == "确定"){
        var val = $(this).siblings("input").val();
        if(!isNaN(val) && ex.test(val) && val>0){
            if(val >99){
                if($(window).width()<1079){
                    $(".sphereFun>div").eq(1).find("label").css("fontSize","8px");
                }else{
                    $(".sphereFun>div").eq(1).find("label").css("fontSize","14px");
                }
            }
            $(".sphereFun>div").eq(1).find("label").html("加倍X"+val).attr("value",val);
            $(".modalBox").css("display","none");
            val = null;
        }else{
            $(".inputAlert").html("请输入大于1的整数").slideDown();
            setTimeout(function(){
                $(".inputAlert").slideUp();
            },2000)
        }
    }else if($(this).html() == "取消"){
        $(".modalBox").css("display","none");
        val = null;
    }
});

//保存着百位个位和十位的所选球  并将它变成红色
$(".positionNum span").click(function(){
    var method = $(".sphereFun>div").eq(0).find("label").html();
    if($.inArray(method,methodArray)==8 && $(this).index()<2){
        alert("只允许选择个位的一个球");
        return 0 ;
    }else if($.inArray(method,methodArray)>8 && $.inArray(method,methodArray)<11 && $(this).index()==0){
        alert("只允许选择个位和十位的两个球");
        return 0 ;
    }
    $(".positionNum span").css("backgroundColor","#D4D2D5");
    $(this).css("backgroundColor","#119F99");
    $(".circle").css("background",bgGray);
    if($(this).html() == "十位"){
        var decade = Number(objThree.decade);
        if(decade>0){
            $(".circle").css("background",bgGray);
            $(".circle").eq(decade -1).css("background",bgRed);
        }
    }else if($(this).html() == "个位"){
        var unit = Number(objThree.unit);
        if(unit>0){
            $(".circle").css("background",bgGray);
            $(".circle").eq(unit -1).css("background",bgRed);
        }
    }else{
        var hundreds = Number(objThree.hundreds);
        if(hundreds>0){
            $(".circle").css("background",bgGray);
            $(".circle").eq(hundreds -1).css("background",bgRed);
        }
    }
});

//点击球
$(".stage .circle label").click(function(){
    var method = $(".sphereFun>div").eq(0).find("label").html();
    var doubleNum = $(".sphereFun>div").eq(1).find("label").html();
    if($.inArray(method,methodArray)>=8){   //如果是组选或者直选
        $(".circle").css("background",bgGray);  //先将所有球变成灰色
        if($(".positionNum span").eq(0).css("backgroundColor") == "rgb(17, 159, 153)"){ //百位
            if($(this).html() == objThree.hundreds){       //如果已经选中了  变灰 删除
                $(this).parent().css("background",bgGray);
                objThree.hundreds = "";
            }else{
                $(this).parent().css("background",bgRed); //选中的球位红色 并加到对象中
                objThree.hundreds = $(this).html();
            }
        }else if($(".positionNum span").eq(1).css("backgroundColor") == "rgb(17, 159, 153)"){ //十位
            if($(this).html() == objThree.decade){       //如果已经选中了  变灰 删除
                $(this).parent().css("background",bgGray);
                objThree.decade = "";
            }else{
                $(this).parent().css("background",bgRed); //选中的球位红色 并加到对象中
                objThree.decade = $(this).html();
            }
        }else{  //个位
            if($(this).html() == objThree.unit){       //如果已经选中了  变灰 删除
                $(this).parent().css("background",bgGray);
                objThree.unit = "";
            }else{
                $(this).parent().css("background",bgRed); //选中的球位红色 并加到对象中
                objThree.unit = $(this).html();
            }
        }
    }else{                                           //否则是任选
        if($.inArray($(this).html(),choiceNum)<0){  //如果数组中没有该球
            $(this).parent().css("background",bgRed);
            choiceNum.push($(this).html());
        }else{                                      //如果有该球
            $(this).parent().css("background",bgGray);
            choiceNum.splice(jQuery.inArray($(this).html(),choiceNum),1);
        }
    }
});

//点击确定
var Total = [];
var source = "";
var allMoney = 0;
$(".middle s").click(function(){   //点击确定后

    $(".circle").css("background",bgGray);   //变灰

    var method = $(".sphereFun>div").eq(0).find("label").html();   //玩法
    var doubleNum = $(".sphereFun>div").eq(1).find("label").html(); //加倍
    var multiple = Number($(".sphereFun>div").eq(1).find("label").attr("value"));
    var num = "";                                  //所选号字符串
    var sAD = "复式";
    var res = null;
    if($.inArray(method,methodArray)>=8){   //如果是组选或者直选 将全部都是单式
        sAD = "单式";
        if($.inArray(method,methodArray)==8){
            num ="  个位"+objThree.unit;
        }else if($.inArray(method,methodArray)>8 && $.inArray(method,methodArray)<11){
            num = "  十位"+objThree.decade+"  个位"+objThree.unit;
        }else{
            num = "百位"+objThree.hundreds+"  十位"+objThree.decade+"  个位"+objThree.unit;
        }
        res = method + ":"+sAD+" "+num+" "+doubleNum + " "+ multiple*2+"元";
        objThree.hundreds = "";
        objThree.decade = "";            //清空
        objThree.unit = "";
    }else{
        num = choiceNum.sort().join(" ");
        if($.inArray(method,methodArray)+1 < choiceNum.length){   //组合
            sAD = "复式";
            var m = choiceNum.length;
            var n = $.inArray(method,methodArray)+1;
            var combinationNumber = factorial(m)/(factorial(n)*(factorial(m-n)));
            multiple *= combinationNumber;
            res = method + "："+sAD+" &nbsp;"+num+" &nbsp;"+doubleNum + " &nbsp;"+ multiple*2+"元";
        }else if($.inArray(method,methodArray)+1 == choiceNum.length) {
            sAD = "单式";
            res = method + ":"+sAD+" &nbsp;"+num+" &nbsp;"+doubleNum + " &nbsp;"+ multiple*2+"元";
        }else{
            var hhh =Number($.inArray(method,methodArray))+1;
            alert("选择的球数不能少于"+hhh+"个");
            res = null;
        }
        choiceNum = [];     //清空
    }

    if(res){
        allMoney += multiple*2;
        source = "determine";   //表明来源是点击确定后  而不是点击已选
        $("#sphere").hide();
        var ppp = "<p>"+res+"</p>";
        $(".displayAllNumber").show().find(".multiLineData").append(ppp);
        Total.push(res);
    }
});

//点击返回 清空
$(".bottomOption button").click(function(){
    if($(this).index() == 0){                 //点击返回
        $("#sphere").show();
        $(".displayAllNumber").hide();
    }else{                                    //点击清空
        if(source == "determine"){            //判断来源
            Total.pop();
        }else if (source == "selected"){
            Total = [];
            $(".bottomOption>.allTotal").html("");
        }
    }
    $(".multiLineData p").remove();
});

//点击已选
$(".sphereFun .last").click(function(){
    source = "selected";
    $("#sphere").hide();
    $(".displayAllNumber").show();
    $(".bottomOption>.allTotal").html("共 : "+ allMoney/2+"注 ， 合计 ： "+allMoney+"元");
    for(var i =0;i<Total.length;i++){
        var ppp = "<p>"+Total[i]+"</p>";
        $(".multiLineData").append(ppp);
    }
});

//点击机选
$(".sphereFun .machineSel>s").click(function(){
    var method = $(".sphereFun>div").eq(0).find("label").html();   //玩法
    $(".sphereNum section figure").css("background",bgGray);
    choiceNum = [];
    objThree.hundreds = "";
    objThree.decade = "";            //清空
    objThree.unit = "";
    if($.inArray(method,methodArray)>=8){   //如果是组选或者直选 将全部都是单式
        if($.inArray(method,methodArray) == 8){
            var id = randUnique(1,12,1);
            $(".sphereNum section").eq(id-1).find("figure").css("background",bgRed);
            objThree.unit =id<10?id="0"+id:id;
        }else if($.inArray(method,methodArray) >9 && $.inArray(method,methodArray) <11){
            var id = randUnique(1,12,2);
            var tag;
            for(var o=1;o<3;o++){
                if($(".positionNum span").eq(o).css("backgroundColor") == "rgb(17, 159, 153)"){
                    tag = o;
                }
            }
            if(tag == 2){  //个位
                tag = 0;
            }else{
                tag = 1;
            }
            $(".sphereNum section").eq(id[tag]-1).find("figure").css("background",bgRed);
            objThree.unit =id[0]<10?id[0]="0"+id[0]:id[0];
            objThree.decade =id[1]<10?id[1]="0"+id[1]:id[1];
        }else{
            var id = randUnique(1,12,3);
            var tag;
            for(var o=0;o<3;o++){
                if($(".positionNum span").eq(o).css("backgroundColor") == "rgb(17, 159, 153)"){
                    tag = o;
                }
            }
            $(".sphereNum section").eq(id[tag]-1).find("figure").css("background",bgRed);
            objThree.hundreds =id[0]<10?id[0]="0"+id[0]:id[0];
            objThree.decade =id[1]<10?id[1]="0"+id[1]:id[1];
            objThree.unit =id[2]<10?id[2]="0"+id[2]:id[2];
        }
    }else{
        if($.inArray(method,methodArray) == 0){
            var id = randUnique(1,12,1);
            $(".sphereNum section").eq(id-1).find("figure").css("background",bgRed);
            choiceNum.push(id<10?id="0"+id:id);
        }else if($.inArray(method,methodArray) == 1){
            var id = randUnique(1,12,2);
            for(var i=0;i<id.length;i++){
                $(".sphereNum section").eq(id[i]-1).find("figure").css("background",bgRed);
                choiceNum.push(id[i]<10?id[i]="0"+id[i]:id[i]);
            }
        }else if($.inArray(method,methodArray) == 2){
            var id = randUnique(1,12,3);
            for(var i=0;i<id.length;i++){
                $(".sphereNum section").eq(id[i]-1).find("figure").css("background",bgRed);
                choiceNum.push(id[i]<10?id[i]="0"+id[i]:id[i]);
            }
        }else if($.inArray(method,methodArray) == 3){
            var id = randUnique(1,12,4);
            for(var i=0;i<id.length;i++){
                $(".sphereNum section").eq(id[i]-1).find("figure").css("background",bgRed);
                choiceNum.push(id[i]<10?id[i]="0"+id[i]:id[i]);
            }
        }else if($.inArray(method,methodArray) == 4){
            var id = randUnique(1,12,5);
            for(var i=0;i<id.length;i++){
                $(".sphereNum section").eq(id[i]-1).find("figure").css("background",bgRed);
                choiceNum.push(id[i]<10?id[i]="0"+id[i]:id[i]);
            }
        }else if($.inArray(method,methodArray) == 5){
            var id = randUnique(1,12,6);
            for(var i=0;i<id.length;i++){
                $(".sphereNum section").eq(id[i]-1).find("figure").css("background",bgRed);
                choiceNum.push(id[i]<10?id[i]="0"+id[i]:id[i]);
            }
        }else if($.inArray(method,methodArray) == 6){
            var id = randUnique(1,12,7);
            for(var i=0;i<id.length;i++){
                $(".sphereNum section").eq(id[i]-1).find("figure").css("background",bgRed);
                choiceNum.push(id[i]<10?id[i]="0"+id[i]:id[i]);
            }
        }else if($.inArray(method,methodArray) == 7){
            var id = randUnique(1,12,8);
            for(var i=0;i<id.length;i++){
                $(".sphereNum section").eq(id[i]-1).find("figure").css("background",bgRed);
                choiceNum.push(id[i]<10?id[i]="0"+id[i]:id[i]);
            }
        }
    }
});

//不重复随机号
function randUnique(start, end, size){
    // 全部随机数值
    var allNums = new Array;

    // 判断获取随机数个数
    size = size ? (size > end - start ? end - start : size) : 1;

    // 生成随机数值区间数组
    for (var i = start, k = 0; i <= end; i++, k++) {
        allNums[k] = i;
    }

    // 打撒数组排序
    allNums.sort(function(){ return 0.5 - Math.random(); });

    // 获取数组从第一个开始到指定个数的下标区间
    return allNums.slice(0, size);
}

//递归调用 计算组合
function factorial(n){
    return n > 1 ? n * factorial(n-1) : 1;
}

//功能区点击事件
$(function () {

    $(".pick").click(function () {

        if($("#functionArea").css("display") == "none"||!$(".optionsList").eq(0).is(":hidden")||!$(".InterfaceColor").eq(0).is(":hidden")){
            $("#sphere").show();
            $("#bottomTable").hide();
            $("#groomNum").hide();
            $("#functionArea").show();
            $(".optionsList").hide();
            $(".InterfaceColor").hide()
        }else{
            $("#sphere").hide();
            $(".displayAllNumber").hide();
            $("#bottomTable").show();
            $("#groomNum").show();
            $("#functionArea").hide();
        }

    });

    $(".menuRight").click(function () {

        if($("#functionArea").is(":hidden")||!$("#sphere").is(":hidden")){
            $("#sphere").hide();
            $("#functionArea").show();    //如果元素为隐藏,则将它显现
            $("#bottomTable").hide();
            $("#groomNum").hide();
        }else{
            $("#functionArea").hide();     //如果元素为显现,则将其隐藏
            $("#bottomTable").show();
            $("#groomNum").show();
        }
        $(".optionsList").show();
        $(".InterfaceColor").hide()
    });
});

//直播开奖等~~~
$(function () {

    //是否直播
    $(".optionsBtn").eq(0).click(function () {
        var closeOrOpen=$(".optionsBtn img").eq(0).attr("src");
        if(closeOrOpen=='img/close.png'){
            $(".optionsBtn img").eq(0).attr("src","img/open.png")
        }else{
            $(".optionsBtn img").eq(0).attr("src","img/close.png")
            //不进行直播
        }
    });

    //红-紫
    $(".optionsBtn").eq(1).click(function () {
        $(".otherOptions").eq(0).toggle();
        if(!$(".otherOptions").eq(0).is(":hidden")){
            $(".otherOptions2").eq(0).css("bottom","300px");
            $(".otherOptions").eq(0).css("bottom","60px")
        }else{
            $(".otherOptions2").eq(0).css("bottom","120px")
        }
    });

    //界面1
    $(".optionsBtn").eq(2).click(function () {
        $(".otherOptions").eq(1).toggle();
        if(!$(".otherOptions").eq(1).is(":hidden")){
            $(".otherOptions2").eq(1).css("bottom","300px");
            $(".otherOptions").eq(1).css("bottom","60px")
        }else{
            $(".otherOptions2").eq(1).css("bottom","120px")
        }

    });

    //选界面颜色
    $(".optionsBtn").eq(3).click(function () {
        $(".optionsList").toggle();
        $(".InterfaceColor").toggle();
    });

    //去圆
    $(".optionsBtn").eq(4).click(function () {
        var closeOrOpen=$(".optionsBtn img").eq(1).attr("src");
        if(closeOrOpen=='img/close.png'){
            $(".optionsBtn img").eq(4).attr("src","img/close.png");
            $(".optionsBtn img").eq(1).attr("src","img/open.png");
            $(".optionalDisRed").css("background","url()");
            $(".optionalDisBlue").css("background","url()");
            $(".optionalDisBlue").css("color","#000000").css("font-weight","800");
            $(".optionalDisRed").css("color","#000000").css("font-weight","800");

        }else{
            $(".optionsBtn img").eq(1).attr("src","img/close.png");
            $(".optionalDisRed").css("background","url(./img/red.png)no-repeat center").css("background-size","16px 18px");
            $(".optionalDisBlue").css("background","url(./img/blue.png)no-repeat center").css("background-size","16px 18px");
            $(".optionsBtn img").eq(3).attr("src","img/open.png");
            $(".optionsBtn img").eq(2).attr("src","img/close.png");

            $(".optionalDisBlue").css("color","#ffffff").css("font-weight","500");
            $(".optionalDisRed").css("color","#ffffff").css("font-weight","500");
        }
    });

    //字体1
    $(".optionsBtn").eq(5).click(function () {
        $(".otherOptions2").eq(0).toggle();
        if(!$(".otherOptions").eq(0).is(":hidden")){
            $(".otherOptions2").eq(0).css("bottom","300px");
            $(".otherOptions").eq(0).css("bottom","60px")
        }else{
            $(".otherOptions2").eq(0).css("bottom","120px")

        }

    });

    //30期
    $(".optionsBtn").eq(6).click(function () {
        $(".otherOptions2").eq(1).toggle();
        if(!$(".otherOptions").eq(1).is(":hidden")){
            $(".otherOptions2").eq(1).css("bottom","300px");
            $(".otherOptions").eq(1).css("bottom","60px")
        }else{
            $(".otherOptions2").eq(1).css("bottom","120px")
        }
    });

    //登录注册
    $(".optionsBtn").eq(7).click(function () {

    });

    //前一字体色
    $(".optionsBtn").eq(8).click(function () {
        $(".optionsBtn img").eq(4).attr("src","img/close.png");
        var closeOrOpen=$(".optionsBtn img").eq(2).attr("src");
        if(closeOrOpen=='img/close.png'){
            $(".optionalDisBlue").css("color","#ffffff").css("font-weight","500");
            $(".optionalDisRed").css("color","#ffffff").css("font-weight","500");
            $(".optionalDisRed").css("background","url(./img/red.png)no-repeat center").css("background-size","16px 18px");
            $(".optionalDisBlue").css("background","url(./img/blue.png)no-repeat center").css("background-size","16px 18px");
            $(".optionsBtn img").eq(2).attr("src","img/open.png");
            $(".optionsBtn img").eq(3).attr("src","img/close.png");
            $(".optionalDisRed").css("background","url(./img/blue.png)no-repeat center").css("background-size","16px 18px");
            //方法
            var first=[];
            for(var i=1;i<$(".dataTable tbody tr").length-1;i++){
                first[i-1]=$(".lotteryNumber").eq(i*5+1).html();
            }
            for(var i=1;i<$(".dataTable tbody tr").length;i++){

                $(".dataTable tbody tr").eq(i-1).find(".optionalDis").eq(first[i-1]-1).css("background","url(./img/red.png)no-repeat center").css("background-size","16px 18px");

            }

        }else{
            $(".optionalDisRed").css("background","url(./img/blue.png)no-repeat center").css("background-size","16px 18px");
            $(".optionsBtn img").eq(2).attr("src","img/close.png");
            $(".optionalDisBlue").css("color","#ffffff").css("font-weight","500");
            $(".optionalDisRed").css("color","#ffffff").css("font-weight","500");
        }
    });

    //前三字体色
    $(".optionsBtn").eq(9).click(function () {
        $(".optionalDisBlue").css("color","#ffffff").css("font-weight","500");
        $(".optionalDisRed").css("color","#ffffff").css("font-weight","500");
        var closeOrOpen=$(".optionsBtn img").eq(3).attr("src");
        if(closeOrOpen=='img/close.png'){
            $(".optionsBtn img").eq(4).attr("src","img/close.png");
            $(".optionalDisRed").css("background","url(./img/red.png)no-repeat center").css("background-size","16px 18px");
            $(".optionalDisBlue").css("background","url(./img/blue.png)no-repeat center").css("background-size","16px 18px");
            $(".optionsBtn img").eq(3).attr("src","img/open.png");
            $(".optionalDisRed").css("background","url(./img/red.png)no-repeat center").css("background-size","16px 18px");
            $(".optionsBtn img").eq(2).attr("src","img/close.png");
        }else{
            $(".optionsBtn img").eq(3).attr("src","img/close.png");
            $(".optionalDisRed").css("background","url(./img/blue.png)no-repeat center").css("background-size","16px 18px");

        }
    });

    //连号背景色
    $(".optionsBtn").eq(10).click(function ewq() {
        $(".optionalDisBlue").css("color","#ffffff").css("font-weight","500");
        $(".optionalDisRed").css("color","#ffffff").css("font-weight","500");
        var closeOrOpen=$(".optionsBtn img").eq(4).attr("src");
        if(closeOrOpen=='img/close.png'){
            $(".optionalDisRed").css("background","url(./img/blue.png)no-repeat center").css("background-size","16px 18px");
            $(".optionalDisBlue").css("background","url(./img/blue.png)no-repeat center").css("background-size","16px 18px");
            $(".optionsBtn img").eq(4).attr("src","img/open.png");
            $(".optionsBtn img").eq(2).attr("src","img/close.png");
            $(".optionsBtn img").eq(3).attr("src","img/close.png");
            //连号处理方法
            var arrX=[];
            for(var i=0;i<obj.length;i++){
                arrX[i]=[];
                for(var j=0;j<obj[i].kaijianghao.length;j++){
                    arrX[i][j]=obj[i].kaijianghao[j];
                }
                arrX[i]=arrX[i].sort(sortNumber);
            }
            console.log(arrX[0]);
            console.log(obj[0].kaijianghao);
            for(var iq=0;iq<arrX.length;iq++){

                var index0= arrX[iq][0];
                var index1= arrX[iq][1];
                var index2= arrX[iq][2];
                var index3= arrX[iq][3];
                var index4= arrX[iq][4];

                if(parseInt(index0)+2==parseInt(index1)+1&&parseInt(index1)+1==index2){
                    $(".dataTable tbody tr").eq(iq).find(".optionalDis").eq(index0-1).css("background","#f60");
                    $(".dataTable tbody tr").eq(iq).find(".optionalDis").eq(index1-1).css("background","#f60");
                    $(".dataTable tbody tr").eq(iq).find(".optionalDis").eq(index2-1).css("background","#f60");
                    if(parseInt(index2)+1==index3){
                        $(".dataTable tbody tr").eq(iq).find(".optionalDis").eq(index3-1).css("background","#f60");
                    }
                    if(parseInt(index2)+1==index3&&parseInt(index3)+1==index4){
                        $(".dataTable tbody tr").eq(iq).find(".optionalDis").eq(index4-1).css("background","#f60");
                    }

                }else if(parseInt(index1)+2==parseInt(index2)+1&&parseInt(index2)+1==index3){
                    $(".dataTable tbody tr").eq(iq).find(".optionalDis").eq(index1-1).css("background","#f60");
                    $(".dataTable tbody tr").eq(iq).find(".optionalDis").eq(index2-1).css("background","#f60");
                    $(".dataTable tbody tr").eq(iq).find(".optionalDis").eq(index3-1).css("background","#f60");
                    if(parseInt(index3)+1==index4){
                        $(".dataTable tbody tr").eq(iq).find(".optionalDis").eq(index4-1).css("background","#f60");
                    }
                }else if(parseInt(index2)+2==parseInt(index3)+1&&parseInt(index3)+1==index4){
                    $(".dataTable tbody tr").eq(iq).find(".optionalDis").eq(index2-1).css("background","#f60");
                    $(".dataTable tbody tr").eq(iq).find(".optionalDis").eq(index3-1).css("background","#f60");
                    $(".dataTable tbody tr").eq(iq).find(".optionalDis").eq(index4-1).css("background","#f60");
                }

            }

        }else{
            $(".optionsBtn img").eq(4).attr("src","img/close.png");
            $(".optionalDisRed").css("background","url(./img/red.png)no-repeat center").css("background-size","16px 18px");
            $(".optionalDisBlue").css("background","url(./img/blue.png)no-repeat center").css("background-size","16px 18px");
            $(".optionsBtn img").eq(3).attr("src","img/open.png");
        }


    });


    function sortNumber(a,b)
    {
        return a - b
    }


    //切换游戏
    $(".optionsBtn").eq(11).click(function () {

    });


    /*选项具体值开始*/
    $(".liStyle1").click(function () {
        var index=$(this).index();
        $(".content23").eq(0).html($(".liStyle1").eq(index).html());
        if(index==0){//红-紫
            $(".lotteryNumber").css("color","#7A056B");


            $(".attentionNumRed").css("color","red");
            $(".heavyNumber").css("color","#7A056B");
            $(".Odd").css("color","#7A056B");
            $(".bigNum").css("color","#7A056B");

            $(".firstThreeTails").css("color","#7A056B");
            $(".firstThreeValuesBs").css("color","#7A056B");
            $(".firstThreeValues").css("color","#7A056B");
            $(".andValueSd").css("color","#7A056B");
            $(".andValueAll").css("color","#7A056B");
            $(".threeLotteryNumber").css("color","#7A056B");
            $(".threeGroupsDis").css("color","#7A056B");
            $(".heavyNumberLine").css("color","#7A056B");

            $(".theFormerLine").css("color","#7A056B");
            $(".theFormer").css("color","#7A056B");
            $(".beforeCrossLine").css("color","#7A056B");
            $(".spanDataTableLine").css("color","#7A056B");
            $(".spanDataTable").css("color","#7A056B");
            $(".beforeCross").css("color","#7A056B");

        }else if(index==1){//红黑
            $(".lotteryNumber").css("color","#000");
            $(".attentionNumRed").css("color","#E10601");
            $(".heavyNumber").css("color","#000");
            $(".Odd").css("color","#E10601");
            $(".bigNum").css("color","#000");

            $(".firstThreeTails").css("color","#000");
            $(".firstThreeValuesBs").css("color","#E10601");
            $(".firstThreeValues").css("color","#E10601");
            $(".andValueSd").css("color","#000");
            $(".andValueAll").css("color","#E10601");
            $(".threeLotteryNumber").css("color","#000");
            $(".threeGroupsDis").css("color","#000");
            $(".heavyNumberLine").css("color","#E10601");

            $(".theFormerLine").css("color","#E10601");
            $(".theFormer").css("color","#E10601");
            $(".beforeCrossLine").css("color","#000");
            $(".spanDataTableLine").css("color","#000");
            $(".spanDataTable").css("color","#E10601");
            $(".beforeCross").css("color","#E10601");
        }else if(index==2){//黑绿
            $(".lotteryNumber").css("color","#006464");
            $(".attentionNumRed").css("color","red");
            $(".heavyNumber").css("color","#000");
            $(".Odd").css("color","#006464");
            $(".bigNum").css("color","#000");

            $(".firstThreeTails").css("color","#000");
            $(".firstThreeValuesBs").css("color","#006464");
            $(".firstThreeValues").css("color","#006464");
            $(".andValueSd").css("color","#000");
            $(".andValueAll").css("color","#006464");
            $(".threeLotteryNumber").css("color","#000");
            $(".threeGroupsDis").css("color","#000");
            $(".heavyNumberLine").css("color","#006464");

            $(".theFormerLine").css("color","#006464");
            $(".theFormer").css("color","#006464");
            $(".beforeCrossLine").css("color","#000");
            $(".spanDataTableLine").css("color","#000");
            $(".spanDataTable").css("color","#006464");
            $(".beforeCross").css("color","#006464");
        }

    });

    $(".liStyle2").click(function () {
        var index=$(this).index();
        $(".content23").eq(1).html($(".liStyle2").eq(index).html());
        if(index==0){//界面1

            $(".optionalDis").show();
            $(".firstCon").show();
            $(".secondCon").show();
            $(".thirdCon").show();
            $(".attentionNum").show();
            $(".heavyNumber").show();
            $(".Odd").show();
            $(".bigNum").show();

            $(".firstThreeTails").hide();
            $(".firstThreeValuesBs").hide();
            $(".firstThreeValues").hide();
            $(".andValueSd").hide();
            $(".andValueAll").hide();
            $(".threeLotteryNumber").hide();
            $(".threeGroupsDis").hide();
            $(".heavyNumberLine").hide();

            $(".theFormerLine").hide();
            $(".theFormer").hide();
            $(".beforeCrossLine").hide();
            $(".spanDataTableLine").hide();
            $(".spanDataTable").hide();
            $(".beforeCross").hide();

            svg(svgObj);
            jiemian1();
        }else if(index==1){//界面2

            $(".optionalDis").show();
            $(".firstCon").hide();
            $(".secondCon").hide();
            $(".thirdCon").hide();
            $(".attentionNum").show();
            $(".heavyNumber").hide();
            $(".Odd").show();
            $(".bigNum").show();

            $(".firstThreeTails").hide();
            $(".firstThreeValuesBs").hide();
            $(".firstThreeValues").hide();
            $(".andValueSd").hide();
            $(".andValueAll").hide();
            $(".threeLotteryNumber").hide();
            $(".threeGroupsDis").show();
            $(".heavyNumberLine").hide();

            $(".theFormerLine").hide();
            $(".theFormer").hide();
            $(".beforeCrossLine").hide();
            $(".spanDataTableLine").hide();
            $(".spanDataTable").hide();
            $(".beforeCross").hide();

            svg(svgObj);
            jiemian1();
        }else if(index==2){//界面3
            $(".optionalDis").show();
            $(".firstCon").hide();
            $(".secondCon").hide();
            $(".thirdCon").hide();
            $(".attentionNum").show();
            $(".heavyNumber").show();
            $(".Odd").hide();
            $(".bigNum").hide();

            $(".firstThreeTails").hide();
            $(".firstThreeValuesBs").hide();
            $(".firstThreeValues").hide();
            $(".andValueSd").show();
            $(".andValueAll").show();
            $(".threeLotteryNumber").show();
            $(".threeGroupsDis").hide();
            $(".heavyNumberLine").show();

            $(".theFormerLine").hide();
            $(".theFormer").hide();
            $(".beforeCrossLine").hide();
            $(".spanDataTableLine").hide();
            $(".spanDataTable").hide();
            $(".beforeCross").hide();

            svg(svgObj);
            jiemian1();
        }

    });

    $(".liStyle3").click(function () {
        var index=$(this).index();
        $(".content23").eq(2).html($(".liStyle3").eq(index).html());
        if(index==0){//字体1
            $(".dataTable").css("font-family","IskoolaPota");
            fontFamily = "IskoolaPota";
            svg(svgObj);
        }else if(index==1){//字体2
            fontFamily = "ZT02";
            $(".dataTable").css("font-family","ZT02");
            svg(svgObj);
        }else if(index==2){//字体3
            fontFamily = "ZT05";
            $(".dataTable").css("font-family","ZT05");
            svg(svgObj);
        }
    });

    $(".liStyle4").click(function (){
        var index=$(this).index();
        $(".content23").eq(3).html($(".liStyle4").eq(index).html());
        var asd=$(".liStyle4").eq($(this).index()).html();
        limit1=asd.substr(0,2);

        $(".dataTable tbody").children("*").remove();
        windowOnLoad();
    });
    /*选项结束*/
    jiemian1();
});

var fontFamily;

//界面初始加载所存在的情况
function jiemian1() {
    $(".InterfaceColor li").eq(0).css("background-color","#6FC2EE");
    $(".CannotBeCancelled").eq(0).css("display","inline-block");


    $(".InterfaceColor li").eq(1).css("background-color","#6FC2EE");
    $(".CannotBeCancelled").eq(1).css("display","inline-block");


    if(!$(".dataTable thead tr .optionalDis").eq(0).is(":hidden")){

        $(".InterfaceColor li").eq(2).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(2).css("display","inline-block");

    }
    if(!$(".dataTable thead tr .firstCon").eq(0).is(":hidden")){
        $(".InterfaceColor li").eq(3).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(3).css("display","inline-block");

    }
    if(!$(".dataTable thead tr .attentionNum").eq(0).is(":hidden")){
        $(".InterfaceColor li").eq(4).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(4).css("display","inline-block");

    }
    if(!$(".dataTable thead tr .threeLotteryNumber").eq(0).is(":hidden")){
        $(".InterfaceColor li").eq(5).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(5).css("display","inline-block");

    }
    if(!$(".dataTable thead tr .heavyNumber").eq(0).is(":hidden")){
        $(".InterfaceColor li").eq(6).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(6).css("display","inline-block");

    }
    if(!$(".dataTable thead tr .firstThreeTails").eq(0).is(":hidden")){
        $(".InterfaceColor li").eq(7).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(7).css("display","inline-block");

    }
    if(!$(".dataTable thead tr .firstThreeValuesBs").eq(0).is(":hidden")){
        $(".InterfaceColor li").eq(8).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(8).css("display","inline-block");

    }
    if(!$(".dataTable thead tr .firstThreeValues").eq(0).is(":hidden")){
        $(".InterfaceColor li").eq(9).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(9).css("display","inline-block");

    }
    if(!$(".dataTable thead tr .andValueSd").eq(0).is(":hidden")){
        $(".InterfaceColor li").eq(10).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(10).css("display","inline-block");

    }
    if(!$(".dataTable thead tr .andValueAll").eq(0).is(":hidden")){
        $(".InterfaceColor li").eq(11).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(11).css("display","inline-block");

    }
    if(!$(".dataTable thead tr .Odd").eq(0).is(":hidden")){
        $(".InterfaceColor li").eq(12).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(12).css("display","inline-block");

    }
    if(!$(".dataTable thead tr .bigNum").eq(0).is(":hidden")){
        $(".InterfaceColor li").eq(13).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(13).css("display","inline-block");

    }
    if(!$(".dataTable thead tr .theFormer").eq(0).is(":hidden")){
        $(".InterfaceColor li").eq(14).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(14).css("display","inline-block");

    }
    if(!$(".dataTable thead tr .theFormerLine").eq(0).is(":hidden")){
        $(".InterfaceColor li").eq(15).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(15).css("display","inline-block");

    }
    if(!$(".dataTable thead tr .heavyNumberLine").eq(0).is(":hidden")){
        $(".InterfaceColor li").eq(16).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(16).css("display","inline-block");

    }
    if(!$(".dataTable thead tr .threeGroupsDis").eq(0).is(":hidden")){
        $(".InterfaceColor li").eq(17).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(17).css("display","inline-block");

    }
    if(!$(".dataTable thead tr .spanDataTable").eq(0).is(":hidden")){
        $(".InterfaceColor li").eq(18).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(18).css("display","inline-block");

    }
    if(!$(".dataTable thead tr .spanDataTableLine").eq(0).is(":hidden")){
        $(".InterfaceColor li").eq(19).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(19).css("display","inline-block");

    }
    if(!$(".dataTable thead tr .beforeCross").eq(0).is(":hidden")){
        $(".InterfaceColor li").eq(20).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(20).css("display","inline-block");
    }
    if(!$(".dataTable thead tr .beforeCrossLine").eq(0).is(":hidden")){
        $(".InterfaceColor li").eq(21).css("background-color","#6FC2EE");
        $(".CannotBeCancelled").eq(21).css("display","inline-block");
    }


}

//增加列！！！
$(function () {

    //任选分布
    $(".InterfaceColor li").eq(2).click(function () {

        if($(".CannotBeCancelled").eq(2).is(":hidden")){
            $(".CannotBeCancelled").eq(2).show();
            $(".InterfaceColor li").eq(2).css("background","#6fc2ee");

            var optionalDis = $("#templateTable .templateTr").children(".optionalDis").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".optionalDis").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".optionalDis").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".optionalDis").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(optionalDis);
            $("#templateTable .templateTrLast").append(optionalDisLast);
            $(".dataTable thead tr").eq(0).append(optionalHeader);
            $(".dataTable thead tr").eq(1).append(optionalHeaderCol);

            $(".optionalDis").show();
            windowOnLoad();
        }
        else{
            $(".InterfaceColor li").eq(2).css("background","#f0f0f0");
            $(".CannotBeCancelled").eq(2).hide();
            $(".optionalDis").hide();
            svg(svgObj);
        }

    });

    //前三位连线
    $(".InterfaceColor li").eq(3).click(function () {
        if ($(".CannotBeCancelled").eq(3).is(":hidden")) {
            $(".CannotBeCancelled").eq(3).show();
            $(".InterfaceColor li").eq(3).css("background", "#6fc2ee");

            var firstCon = $("#templateTable .templateTr").children(".firstCon").remove();
            var firstConLast = $("#templateTable .templateTrLast").children(".firstCon").remove();
            var firstConHeader = $(".dataTable thead tr").eq(0).find(".firstCon").remove();
            var firstConHeaderCol = $(".dataTable thead tr").eq(1).find(".firstCon").remove();

            var secondCon = $("#templateTable .templateTr").children(".secondCon").remove();
            var secondConLast = $("#templateTable .templateTrLast").children(".secondCon").remove();
            var secondConHeader = $(".dataTable thead tr").eq(0).find(".secondCon").remove();
            var secondConHeaderCol = $(".dataTable thead tr").eq(1).find(".secondCon").remove();

            var thirdCon = $("#templateTable .templateTr").children(".thirdCon").remove();
            var thirdConLast = $("#templateTable .templateTrLast").children(".thirdCon").remove();
            var thirdConHeader = $(".dataTable thead tr").eq(0).find(".thirdCon").remove();
            var thirdConHeaderCol = $(".dataTable thead tr").eq(1).find(".thirdCon").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(firstCon);
            $("#templateTable .templateTrLast").append(firstConLast);
            $(".dataTable thead tr").eq(0).append(firstConHeader);
            $(".dataTable thead tr").eq(1).append(firstConHeaderCol);

            $("#templateTable .templateTr").append(secondCon);
            $("#templateTable .templateTrLast").append(secondConLast);
            $(".dataTable thead tr").eq(0).append(secondConHeader);
            $(".dataTable thead tr").eq(1).append(secondConHeaderCol);

            $("#templateTable .templateTr").append(thirdCon);
            $("#templateTable .templateTrLast").append(thirdConLast);
            $(".dataTable thead tr").eq(0).append(thirdConHeader);
            $(".dataTable thead tr").eq(1).append(thirdConHeaderCol);


            $(".firstCon").show();
            $(".secondCon").show();
            $(".thirdCon").show();

            windowOnLoad();
        }

        else {
            $(".firstCon").hide();
            $(".secondCon").hide();
            $(".thirdCon").hide();

            $(".InterfaceColor li").eq(3).css("background", "#f0f0f0");
            $(".CannotBeCancelled").eq(3).hide();
            svg(svgObj);
        }
    });

    //关注号码
    $(".InterfaceColor li").eq(4).click(function () {

        if($(".CannotBeCancelled").eq(4).is(":hidden")){
            $(".CannotBeCancelled").eq(4).show();
            $(".InterfaceColor li").eq(4).css("background","#6fc2ee");

            var optionalDis = $("#templateTable .templateTr").children(".attentionNum").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".attentionNum").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".attentionNum").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".attentionNum").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(optionalDis);
            $("#templateTable .templateTrLast").append(optionalDisLast);
            $(".dataTable thead tr").eq(0).append(optionalHeader);
            $(".dataTable thead tr").eq(1).append(optionalHeaderCol);

            $(".attentionNum").show();
            windowOnLoad();
        }

        else{
            $(".InterfaceColor li").eq(4).css("background","#f0f0f0");
            $(".CannotBeCancelled").eq(4).hide();
            $(".attentionNum").hide();
            svg(svgObj);
        }

    });

    //3位开奖号
    $(".InterfaceColor li").eq(5).click(function () {

        if($(".CannotBeCancelled").eq(5).is(":hidden")){
            $(".CannotBeCancelled").eq(5).show();
            $(".InterfaceColor li").eq(5).css("background","#6fc2ee");

            var optionalDis = $("#templateTable .templateTr").children(".threeLotteryNumber").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".threeLotteryNumber").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".threeLotteryNumber").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".threeLotteryNumber").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(optionalDis);
            $("#templateTable .templateTrLast").append(optionalDisLast);
            $(".dataTable thead tr").eq(0).append(optionalHeader);
            $(".dataTable thead tr").eq(1).append(optionalHeaderCol);

            $(".threeLotteryNumber").show();
            windowOnLoad();
        }

        else{
            $(".InterfaceColor li").eq(5).css("background","#f0f0f0");
            $(".CannotBeCancelled").eq(5).hide();
            $(".threeLotteryNumber").hide();
            svg(svgObj);
        }

    });

    //重号
    $(".InterfaceColor li").eq(6).click(function () {

        if($(".CannotBeCancelled").eq(6).is(":hidden")){
            $(".CannotBeCancelled").eq(6).show();
            $(".InterfaceColor li").eq(6).css("background","#6fc2ee");

            var optionalDis = $("#templateTable .templateTr").children(".heavyNumber").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".heavyNumber").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".heavyNumber").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".heavyNumber").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(optionalDis);

            $("#templateTable .templateTrLast").append(optionalDisLast);
            $(".dataTable thead tr").eq(0).append(optionalHeader);
            $(".dataTable thead tr").eq(1).append(optionalHeaderCol);

            $(".heavyNumber").show();

            windowOnLoad();
        } else{

            var optionalDis = $("#templateTable .templateTr").children(".heavyNumber").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".heavyNumber").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".heavyNumber").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".heavyNumber").remove();
            $(".InterfaceColor li").eq(6).css("background","#f0f0f0");
            $(".CannotBeCancelled").eq(6).hide();
            $(".heavyNumber").hide();
            svg(svgObj);
        }

    });

    //前和尾连线
    $(".InterfaceColor li").eq(7).click(function () {

        if($(".CannotBeCancelled").eq(7).is(":hidden")){
            $(".CannotBeCancelled").eq(7).show();
            $(".InterfaceColor li").eq(7).css("background","#6fc2ee");

            var optionalDis = $("#templateTable .templateTr").children(".firstThreeTails").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".firstThreeTails").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".firstThreeTails").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".firstThreeTails").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(optionalDis);
            $("#templateTable .templateTrLast").append(optionalDisLast);
            $(".dataTable thead tr").eq(0).append(optionalHeader);
            $(".dataTable thead tr").eq(1).append(optionalHeaderCol);

            $(".firstThreeTails").show();
            windowOnLoad();
        }

        else{

            $(".InterfaceColor li").eq(7).css("background","#f0f0f0");
            $(".CannotBeCancelled").eq(7).hide();
            $(".firstThreeTails").hide();
            //svg();
            windowOnLoad();
        }

    });

    //和值大小
    $(".InterfaceColor li").eq(8).click(function () {

        if($(".CannotBeCancelled").eq(8).is(":hidden")){
            $(".CannotBeCancelled").eq(8).show();
            $(".InterfaceColor li").eq(8).css("background","#6fc2ee");

            var optionalDis = $("#templateTable .templateTr").children(".firstThreeValuesBs").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".firstThreeValuesBs").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".firstThreeValuesBs").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".firstThreeValuesBs").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(optionalDis);
            $("#templateTable .templateTrLast").append(optionalDisLast);
            $(".dataTable thead tr").eq(0).append(optionalHeader);
            $(".dataTable thead tr").eq(1).append(optionalHeaderCol);

            $(".firstThreeValuesBs").show();
            windowOnLoad();
        }

        else{
            $(".InterfaceColor li").eq(8).css("background","#f0f0f0");
            $(".CannotBeCancelled").eq(8).hide();
            $(".firstThreeValuesBs").hide();
            svg(svgObj);
        }

    });

    //前值
    $(".InterfaceColor li").eq(9).click(function () {

        if($(".CannotBeCancelled").eq(9).is(":hidden")){
            $(".CannotBeCancelled").eq(9).show();
            $(".InterfaceColor li").eq(9).css("background","#6fc2ee");

            var optionalDis = $("#templateTable .templateTr").children(".firstThreeValues").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".firstThreeValues").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".firstThreeValues").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".firstThreeValues").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(optionalDis);
            $("#templateTable .templateTrLast").append(optionalDisLast);
            $(".dataTable thead tr").eq(0).append(optionalHeader);
            $(".dataTable thead tr").eq(1).append(optionalHeaderCol);

            $(".firstThreeValues").show();
            windowOnLoad();
        }

        else{
            $(".InterfaceColor li").eq(9).css("background","#f0f0f0");
            $(".CannotBeCancelled").eq(9).hide();
            $(".firstThreeValues").hide();
            svg(svgObj);
        }

    });

    //和值单双
    $(".InterfaceColor li").eq(10).click(function () {

        if($(".CannotBeCancelled").eq(10).is(":hidden")){
            $(".CannotBeCancelled").eq(10).show();
            $(".InterfaceColor li").eq(10).css("background","#6fc2ee");

            var optionalDis = $("#templateTable .templateTr").children(".andValueSd").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".andValueSd").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".andValueSd").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".andValueSd").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(optionalDis);
            $("#templateTable .templateTrLast").append(optionalDisLast);
            $(".dataTable thead tr").eq(0).append(optionalHeader);
            $(".dataTable thead tr").eq(1).append(optionalHeaderCol);

            $(".andValueSd").show();
            windowOnLoad();
        }

        else{
            $(".InterfaceColor li").eq(10).css("background","#f0f0f0");
            $(".CannotBeCancelled").eq(10).hide();
            $(".andValueSd").hide();
            svg(svgObj);
        }

    });

    //和值
    $(".InterfaceColor li").eq(11).click(function () {

        if($(".CannotBeCancelled").eq(11).is(":hidden")){
            $(".CannotBeCancelled").eq(11).show();
            $(".InterfaceColor li").eq(11).css("background","#6fc2ee");

            var optionalDis = $("#templateTable .templateTr").children(".andValueAll").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".andValueAll").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".andValueAll").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".andValueAll").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(optionalDis);
            $("#templateTable .templateTrLast").append(optionalDisLast);
            $(".dataTable thead tr").eq(0).append(optionalHeader);
            $(".dataTable thead tr").eq(1).append(optionalHeaderCol);

            $(".andValueAll").show();
            windowOnLoad();
        }

        else{
            $(".InterfaceColor li").eq(11).css("background","#f0f0f0");
            $(".CannotBeCancelled").eq(11).hide();
            $(".andValueAll").hide();
            svg(svgObj);
        }

    });

    //奇数
    $(".InterfaceColor li").eq(12).click(function () {

        if($(".CannotBeCancelled").eq(12).is(":hidden")){
            $(".CannotBeCancelled").eq(12).show();
            $(".InterfaceColor li").eq(12).css("background","#6fc2ee");

            var optionalDis = $("#templateTable .templateTr").children(".Odd").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".Odd").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".Odd").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".Odd").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(optionalDis);
            $("#templateTable .templateTrLast").append(optionalDisLast);
            $(".dataTable thead tr").eq(0).append(optionalHeader);
            $(".dataTable thead tr").eq(1).append(optionalHeaderCol);

            $(".Odd").show();
            windowOnLoad();
        }

        else{
            $(".InterfaceColor li").eq(12).css("background","#f0f0f0");
            $(".CannotBeCancelled").eq(12).hide();
            $(".Odd").hide();
            svg(svgObj);
        }

    });

    //大数
    $(".InterfaceColor li").eq(13).click(function () {

        if($(".CannotBeCancelled").eq(13).is(":hidden")){
            $(".CannotBeCancelled").eq(13).show();
            $(".InterfaceColor li").eq(13).css("background","#6fc2ee");

            var optionalDis = $("#templateTable .templateTr").children(".bigNum").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".bigNum").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".bigNum").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".bigNum").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(optionalDis);
            $("#templateTable .templateTrLast").append(optionalDisLast);
            $(".dataTable thead tr").eq(0).append(optionalHeader);
            $(".dataTable thead tr").eq(1).append(optionalHeaderCol);

            $(".bigNum").show();
            windowOnLoad();
        }

        else{
            $(".InterfaceColor li").eq(13).css("background","#f0f0f0");
            $(".CannotBeCancelled").eq(13).hide();
            $(".bigNum").hide();
            svg(svgObj);
        }

    });

    //前重
    $(".InterfaceColor li").eq(14).click(function () {

        if($(".CannotBeCancelled").eq(14).is(":hidden")){
            $(".CannotBeCancelled").eq(14).show();
            $(".InterfaceColor li").eq(14).css("background","#6fc2ee");

            var optionalDis = $("#templateTable .templateTr").children(".theFormer").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".theFormer").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".theFormer").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".theFormer").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(optionalDis);
            $("#templateTable .templateTrLast").append(optionalDisLast);
            $(".dataTable thead tr").eq(0).append(optionalHeader);
            $(".dataTable thead tr").eq(1).append(optionalHeaderCol);

            $(".theFormer").show();
            windowOnLoad();
        }

        else{
            $(".InterfaceColor li").eq(14).css("background","#f0f0f0");
            $(".CannotBeCancelled").eq(14).hide();
            $(".theFormer").hide();
            svg(svgObj);
        }

    });

    //前重连线
    $(".InterfaceColor li").eq(15).click(function () {

        if($(".CannotBeCancelled").eq(15).is(":hidden")){
            $(".CannotBeCancelled").eq(15).show();
            $(".InterfaceColor li").eq(15).css("background","#6fc2ee");

            var optionalDis = $("#templateTable .templateTr").children(".theFormerLine").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".theFormerLine").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".theFormerLine").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".theFormerLine").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(optionalDis);
            $("#templateTable .templateTrLast").append(optionalDisLast);
            $(".dataTable thead tr").eq(0).append(optionalHeader);
            $(".dataTable thead tr").eq(1).append(optionalHeaderCol);

            $(".theFormerLine").show();
            windowOnLoad();
        }

        else{
            $(".InterfaceColor li").eq(15).css("background","#f0f0f0");
            $(".CannotBeCancelled").eq(15).hide();
            $(".theFormerLine").hide();
            svg(svgObj);
        }

    });

    //重号连线
    $(".InterfaceColor li").eq(16).click(function () {

        if($(".CannotBeCancelled").eq(16).is(":hidden")){
            $(".CannotBeCancelled").eq(16).show();
            $(".InterfaceColor li").eq(16).css("background","#6fc2ee");

            var optionalDis = $("#templateTable .templateTr").children(".heavyNumberLine").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".heavyNumberLine").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".heavyNumberLine").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".heavyNumberLine").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(optionalDis);
            $("#templateTable .templateTrLast").append(optionalDisLast);
            $(".dataTable thead tr").eq(0).append(optionalHeader);
            $(".dataTable thead tr").eq(1).append(optionalHeaderCol);

            $(".heavyNumberLine").show();
            windowOnLoad();
        }

        else{
            $(".InterfaceColor li").eq(16).css("background","#f0f0f0");
            $(".CannotBeCancelled").eq(16).hide();
            $(".heavyNumberLine").hide();
            svg(svgObj);
        }

    });

    //前三组分布
    $(".InterfaceColor li").eq(17).click(function () {

        if($(".CannotBeCancelled").eq(17).is(":hidden")){
            $(".CannotBeCancelled").eq(17).show();
            $(".InterfaceColor li").eq(17).css("background","#6fc2ee");

            var optionalDis = $("#templateTable .templateTr").children(".threeGroupsDis").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".threeGroupsDis").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".threeGroupsDis").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".threeGroupsDis").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(optionalDis);
            $("#templateTable .templateTrLast").append(optionalDisLast);
            $(".dataTable thead tr").eq(0).append(optionalHeader);
            $(".dataTable thead tr").eq(1).append(optionalHeaderCol);

            $(".threeGroupsDis").show();
            windowOnLoad();
        }

        else{
            $(".InterfaceColor li").eq(17).css("background","#f0f0f0");
            $(".CannotBeCancelled").eq(17).hide();
            $(".threeGroupsDis").hide();
            svg(svgObj);
        }

    });

    //跨度
    $(".InterfaceColor li").eq(18).click(function () {

        if($(".CannotBeCancelled").eq(18).is(":hidden")){
            $(".CannotBeCancelled").eq(18).show();
            $(".InterfaceColor li").eq(18).css("background","#6fc2ee");

            var optionalDis = $("#templateTable .templateTr").children(".spanDataTable").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".spanDataTable").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".spanDataTable").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".spanDataTable").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(optionalDis);
            $("#templateTable .templateTrLast").append(optionalDisLast);
            $(".dataTable thead tr").eq(0).append(optionalHeader);
            $(".dataTable thead tr").eq(1).append(optionalHeaderCol);

            $(".spanDataTable").show();
            windowOnLoad();
        }

        else{
            $(".InterfaceColor li").eq(18).css("background","#f0f0f0");
            $(".CannotBeCancelled").eq(18).hide();
            $(".spanDataTable").hide();
            svg(svgObj);
        }

    });

    //跨度连线
    $(".InterfaceColor li").eq(19).click(function () {

        if($(".CannotBeCancelled").eq(19).is(":hidden")){
            $(".CannotBeCancelled").eq(19).show();
            $(".InterfaceColor li").eq(19).css("background","#6fc2ee");

            var optionalDis = $("#templateTable .templateTr").children(".spanDataTableLine").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".spanDataTableLine").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".spanDataTableLine").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".spanDataTableLine").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(optionalDis);
            $("#templateTable .templateTrLast").append(optionalDisLast);
            $(".dataTable thead tr").eq(0).append(optionalHeader);
            $(".dataTable thead tr").eq(1).append(optionalHeaderCol);

            $(".spanDataTableLine").show();
            windowOnLoad();
        }

        else{
            $(".InterfaceColor li").eq(19).css("background","#f0f0f0");
            $(".CannotBeCancelled").eq(19).hide();
            $(".spanDataTableLine").hide();
            svg(svgObj);
        }

    });

    //前跨
    $(".InterfaceColor li").eq(20).click(function () {

        if($(".CannotBeCancelled").eq(20).is(":hidden")){
            $(".CannotBeCancelled").eq(20).show();
            $(".InterfaceColor li").eq(20).css("background","#6fc2ee");

            var optionalDis = $("#templateTable .templateTr").children(".beforeCross").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".beforeCross").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".beforeCross").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".beforeCross").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(optionalDis);
            $("#templateTable .templateTrLast").append(optionalDisLast);
            $(".dataTable thead tr").eq(0).append(optionalHeader);
            $(".dataTable thead tr").eq(1).append(optionalHeaderCol);

            $(".beforeCross").show();
            windowOnLoad();
        }

        else{
            $(".InterfaceColor li").eq(20).css("background","#f0f0f0");
            $(".CannotBeCancelled").eq(20).hide();
            $(".beforeCross").hide();
            svg(svgObj);
        }

    });

    //前跨连线
    $(".InterfaceColor li").eq(21).click(function () {

        if($(".CannotBeCancelled").eq(21).is(":hidden")){
            $(".CannotBeCancelled").eq(21).show();
            $(".InterfaceColor li").eq(21).css("background","#6fc2ee");

            var optionalDis = $("#templateTable .templateTr").children(".beforeCrossLine").remove();
            var optionalDisLast = $("#templateTable .templateTrLast").children(".beforeCrossLine").remove();
            var optionalHeader = $(".dataTable thead tr").eq(0).find(".beforeCrossLine").remove();
            var optionalHeaderCol = $(".dataTable thead tr").eq(1).find(".beforeCrossLine").remove();
            $(".dataTable tbody").children("*").remove();

            $("#templateTable .templateTr").append(optionalDis);
            $("#templateTable .templateTrLast").append(optionalDisLast);
            $(".dataTable thead tr").eq(0).append(optionalHeader);
            $(".dataTable thead tr").eq(1).append(optionalHeaderCol);

            $(".beforeCrossLine").show();
            windowOnLoad();
        }

        else{
            $(".InterfaceColor li").eq(21).css("background","#f0f0f0");
            $(".CannotBeCancelled").eq(21).hide();
            $(".beforeCrossLine").hide();
            svg(svgObj);
        }


    });
});

//取消inputcolor的点击事件。
$("input[type='color']").click(function (e) {
    e.stopPropagation();
});

//字体颜色改变
$(function () {
    //前三奖号
    $(".color").eq(0).change(function () {
        $("#qihao th").css("background-color",$(this).val());
        $(".issueTwo").css("background-color",$(this).val());
        $(".shuzhifang .statisticsRowLeft").css("background-color","#00a6a6");
    });
    $(".color1").eq(0).change(function () {
        $("#qihao th").css("color",$(this).val());
        $(".issueTwo").css("color",$(this).val());
        $(".shuzhifang .statisticsRowLeft").css("color","#000");
    });

    //5位开奖号
    $(".color").eq(1).change(function () {

        $(".lotteryNumber").css("background-color",$(this).val());
        $(".statisticsRow .lotteryNumber").css("background-color","#00a6a6");
    });
    $(".color1").eq(1).change(function () {

        $(".lotteryNumber").css("color",$(this).val());
        $(".statisticsRow .lotteryNumber").css("color","#000");


    });

    //任选分布
    $(".color").eq(2).change(function () {
        $(".optionalDis").css("background-color",$(this).val());
        $(".statisticsRow .optionalDis").css("background-color","#00a6a6");
        $(".templateTrLast .optionalDis").css("background-color","#DBECC7");
    });
    $(".color1").eq(2).change(function () {
        $(".optionalDis").css("color",$(this).val());
        $(".missVlu").css("color","#999999");
        $(".statisticsRow .optionalDis").css("color","#006464");

    });

    //前三位连线
    $(".color").eq(3).change(function () {
        $(".firstCon").css("background-color",$(this).val());
        $(".secondCon").css("background-color",$(this).val());
        $(".thirdCon").css("background-color",$(this).val());

        $(".statisticsRow .firstCon").css("background-color","#00a6a6");
        $(".statisticsRow .secondCon").css("background-color","#00a6a6");
        $(".statisticsRow .thirdCon").css("background-color","#00a6a6");

        $(".templateTrLast  .firstCon").css("background-color","#EFF9EE");
        $(".templateTrLast  .secondCon").css("background-color","#EFF9EE");
        $(".templateTrLast  .thirdCon").css("background-color","#EFF9EE");
        svgObj[0].bgColor = $(this).val();
        svg(svgObj);
    });
    $(".color1").eq(3).change(function () {
        $(".firstCon").css("color",$(this).val());
        $(".secondCon").css("color",$(this).val());
        $(".thirdCon").css("color",$(this).val());

        $(".statisticsRow .firstCon").css("color","#000");
        $(".statisticsRow .secondCon").css("color","#000");
        $(".statisticsRow .thirdCon").css("color","#000");
        svgObj[0].fontColor = $(this).val();
        svg(svgObj);
    });


    //关注号码
    $(".color").eq(4).change(function () {
        $(".attentionNum").css("background-color",$(this).val());
        $(".statisticsRow .attentionNum").css("background-color","#00a6a6");
    });
    $(".color1").eq(4).change(function () {
        $(".attentionNum").css("color",$(this).val());
        $(".attentionNumRed").css("color","red");
        $(".statisticsRow .attentionNum").css("color","#000");
    });

    //三位开奖号
    $(".color").eq(5).change(function () {
        $(".threeLotteryNumber").css("background-color",$(this).val());
        $(".statisticsRow .threeLotteryNumber").css("background-color","#00a6a6");
        $(".templateTrLast .threeLotteryNumber").css("background-color","#F1F1D6");
    });
    $(".color1").eq(5).change(function () {
        $(".threeLotteryNumber").css("color",$(this).val());
        $(".statisticsRow .threeLotteryNumber").css("color","#000");
    });


    //重号
    $(".color").eq(6).change(function () {
        $(".heavyNumber").css("background-color",$(this).val());
        $(".statisticsRow .heavyNumber").css("background-color","#00a6a6");
        $(".templateTrLast .heavyNumber").css("background-color","#F1F1D6");
    });
    $(".color1").eq(6).change(function () {
        $(".heavyNumber").css("color",$(this).val());
        $(".statisticsRow .heavyNumber").css("color","#000");
    });

    //前三和尾连线 var colorTails="#F1F1D6"
    $(".color").eq(7).change(function () {
        $(".firstThreeTails").css("background-color",$(this).val());
        $(".statisticsRow .firstThreeTails").css("background-color","#00a6a6");
        $(".templateTrLast .firstThreeTails").css("background-color","#F1F1D6");
        svgObj[1].bgColor = $(this).val();
        svg(svgObj);
    });
    $(".color1").eq(7).change(function () {
        $(".firstThreeTails").css("color",$(this).val());
        $(".statisticsRow .firstThreeTails").css("color","#000");
        svgObj[1].fontColor = $(this).val();
        svg(svgObj);
    });

    //和值大小
    $(".color").eq(8).change(function () {
        $(".firstThreeValuesBs").css("background-color",$(this).val());
        $(".statisticsRow .firstThreeValuesBs").css("background-color","#00a6a6");
        $(".templateTrLast .firstThreeValuesBs").css("background-color","#F1F1D6");
    });
    $(".color1").eq(8).change(function () {
        $(".firstThreeValuesBs").css("color",$(this).val());
        $(".statisticsRow .firstThreeValuesBs").css("color","#000");
    });

    //前值
    $(".color").eq(9).change(function () {
        $(".firstThreeValues").css("background-color",$(this).val());
        $(".statisticsRow .firstThreeValues").css("background-color","#00a6a6");
        $(".templateTrLast .firstThreeValues").css("background-color","#F1F1D6");
    });
    $(".color1").eq(9).change(function () {
        $(".firstThreeValues").css("color",$(this).val());
        $(".statisticsRow .firstThreeValues").css("color","#000");
    });

    //和值单双
    $(".color").eq(10).change(function () {
        $(".andValueSd").css("background-color",$(this).val());
        $(".statisticsRow .andValueSd").css("background-color","#00a6a6");
        $(".templateTrLast .andValueSd").css("background-color","#F1F1D6");
    });
    $(".color1").eq(10).change(function () {
        $(".andValueSd").css("color",$(this).val());
        $(".statisticsRow .andValueSd").css("color","#000");
    });

    //和值
    $(".color").eq(11).change(function () {
        $(".andValueAll").css("background-color",$(this).val());
        $(".statisticsRow .andValueAll").css("background-color","#00a6a6");
        $(".templateTrLast .andValueAll").css("background-color","#F1F1D6");
    });
    $(".color1").eq(11).change(function () {
        $(".andValueAll").css("color",$(this).val());
        $(".statisticsRow .andValueAll").css("color","#000");
    });

    //奇数
    $(".color").eq(12).change(function () {
        $(".Odd").css("background-color",$(this).val());
        $(".statisticsRow .Odd").css("background-color","#00a6a6");
        $(".templateTrLast .Odd").css("background-color","#F1F1D6");
    });
    $(".color1").eq(12).change(function () {
        $(".Odd").css("color",$(this).val());
        $(".statisticsRow .Odd").css("color","#000");
    });

    //大数
    $(".color").eq(13).change(function () {
        $(".bigNum").css("background-color",$(this).val());
        $(".statisticsRow .bigNum").css("background-color","#00a6a6");
        $(".templateTrLast .bigNum").css("background-color","#F1F1D6");
    });
    $(".color1").eq(13).change(function () {
        $(".bigNum").css("color",$(this).val());
        $(".statisticsRow .bigNum").css("color","#000");
    });

    //前重
    $(".color").eq(14).change(function () {
        $(".theFormer").css("background-color",$(this).val());
        $(".statisticsRow .theFormer").css("background-color","#00a6a6");
        $(".templateTrLast .theFormer").css("background-color","#F1F1D6");
    });
    $(".color1").eq(14).change(function () {
        $(".theFormer").css("color",$(this).val());
        $(".statisticsRow .theFormer").css("color","#000");
    });



    //前重连线 colorFormer="#F1F1D6"
    $(".color").eq(15).change(function () {
        $(".theFormerLine").css("background-color",$(this).val());
        $(".statisticsRow .theFormerLine").css("background-color","#00a6a6");
        $(".templateTrLast .theFormerLine").css("background-color","#F1F1D6");
        svgObj[2].bgColor = $(this).val();
        svg(svgObj);
    });
    $(".color1").eq(15).change(function () {
        $(".theFormerLine").css("color",$(this).val());
        $(".statisticsRow .theFormerLine").css("color","#000");
        svgObj[2].fontColor = $(this).val();
        svg(svgObj);
    });

    //重号连线
    /*
     *  var colorHeavy="#F1F1D6";//重号连线
     var colorSpan="#dbecc7";//跨度连线
     var colorCross="#FFD2E9";//前跨连线
     * */
    $(".color").eq(16).change(function () {
        $(".heavyNumberLine").css("background-color",$(this).val());
        $(".statisticsRow .heavyNumberLine").css("background-color","#00a6a6");
        $(".templateTrLast .heavyNumberLine").css("background-color","#F1F1D6");
        svgObj[3].bgColor = $(this).val();
        svg(svgObj);
    });
    $(".color1").eq(16).change(function () {
        $(".heavyNumberLine").css("color",$(this).val());
        $(".statisticsRow .heavyNumberLine").css("color","#000");
        svgObj[3].fontColor = $(this).val();
        svg(svgObj);
    });


    //前三组分布
    $(".color").eq(17).change(function () {
        $(".threeGroupsDis").css("background-color",$(this).val());
        $(".statisticsRow .threeGroupsDis").css("background-color","#00a6a6");
        $(".templateTrLast .threeGroupsDis").css("background-color","#F1F1D6");
    });
    $(".color1").eq(17).change(function () {
        $(".threeGroupsDis").css("color",$(this).val());
        $(".statisticsRow .threeGroupsDis").css("color","#000");
    });

    //跨度
    $(".color").eq(18).change(function () {
        $(".spanDataTable").css("background-color",$(this).val());
        $(".statisticsRow .spanDataTable").css("background-color","#00a6a6");
        $(".templateTrLast .spanDataTable").css("background-color","#F1F1D6");
    });
    $(".color1").eq(18).change(function () {
        $(".spanDataTable").css("color",$(this).val());
        $(".statisticsRow .spanDataTable").css("color","#000");
    });


    //跨度连线 var colorSpan="#dbecc7";//跨度连线

    $(".color").eq(19).change(function () {
        $(".spanDataTableLine").css("background-color",$(this).val());
        $(".statisticsRow .spanDataTableLine").css("background-color","#00a6a6");
        $(".templateTrLast .spanDataTableLine").css("background-color","#F1F1D6");
        svgObj[4].bgColor = $(this).val();
        svg(svgObj);
    });
    $(".color1").eq(19).change(function () {
        $(".spanDataTableLine").css("color",$(this).val());
        $(".statisticsRow .spanDataTableLine").css("color","#000");
        svgObj[4].fontColor = $(this).val();
        svg(svgObj);
    });

    //前跨
    $(".color").eq(20).change(function () {
        $(".beforeCross").css("background-color",$(this).val());
        $(".statisticsRow .beforeCross").css("background-color","#00a6a6");
        $(".templateTrLast .beforeCross").css("background-color","#F1F1D6");
    });
    $(".color1").eq(20).change(function () {
        $(".beforeCross").css("color",$(this).val());
        $(".statisticsRow .beforeCross").css("color","#000");
    });


    //前跨连线//var colorCross="#FFD2E9";//前跨连线
    $(".color").eq(21).change(function () {
        $(".beforeCrossLine").css("background-color",$(this).val());
        $(".statisticsRow .beforeCrossLine").css("background-color","#00a6a6");
        $(".templateTrLast .beforeCrossLine").css("background-color","#F1F1D6");
        svgObj[5].bgColor = $(this).val();
        svg(svgObj);
    });
    $(".color1").eq(21).change(function () {
        $(".beforeCrossLine").css("color",$(this).val());
        $(".statisticsRow .beforeCrossLine").css("color","#000");
        svgObj[5].fontColor = $(this).val();
        svg(svgObj);
    });

    //连线颜色
    $(".color").eq(22).change(function () {
        svgObj[6].lineColor = $(this).val();
        svg(svgObj);
    });



});

//IE兼容性处理
$(function () {

    //ie?
    if (!!window.ActiveXObject || "ActiveXObject" in window){
        //是
        $(".CannotBeCancelled").html("IE暂不支持");
        $(".bgColor12").css("display","none");
        $(".color").css("display","none");
        $(".color1").css("display","none");
        $(".fontColor12").css("display","none");
        alert("部分功能不能被IE内核浏览器兼容，请谨慎使用")

    }else{
        //不是

    }

});


var limit1=20;
var cssObj={
    zhibo:false,
    zitisheG:2,
    jiemian:0,
    quyuan:false,
    ziti:1,
    qishu:20,
    qianyiziti:false,
    qiansanziti:true,
    lianhaobeijing:false,
    Color:{
        qihaobg:$(".issue").css("background-color"),
        qihaofc:$(".issue").css("color"),
        wuweikaijianghaobg:$(".lotteryNumber").css("background-color"),
        wuweikaijianghaofc:$(".lotteryNumber").css("color"),
        renxuanfenbubg:$(".lotteryNumber").css("background-color"),
        renxuanfenbufc:$(".lotteryNumber").css("color"),
        qiansanweilianxianbg:$(".firstCon").css("background-color"),
        qiansanweilianxianfc:$(".firstCon").css("color"),
        guanzhuhaomabg:$(".attentionNum").css("background-color"),
        guanzhuhaomafc:$(".attentionNum").css("color"),
        sanweikaijianghaobg:$(".threeLotteryNumber").css("background-color"),
        sanweikaijianghaofc:$(".threeLotteryNumber").css("color"),
        qiansanheweilianxianbg:$(".firstThreeTails").css("background-color"),
        qiansanheweilianxianfc:$(".firstThreeTails").css("color"),
        hezhidaxiaobg:$(".firstThreeValuesBs").css("background-color"),
        hezhidaxiaofc:$(".firstThreeValuesBs").css("color"),
        qianzhibg:$(".firstThreeValues").css("background-color"),
        qianzhifc:$(".firstThreeValues").css("color"),
        hezhidanshuangbg:$(".andValueSd").css("background-color"),
        hezhidanshuangfc:$(".andValueSd").css("color"),
        hezhibg:$(".andValueAll").css("background-color"),
        hezhifc:$(".andValueAll").css("color"),
        jishubg:$(".Odd").css("background-color"),
        jishufc:$(".Odd").css("color"),
        dashubg:$(".bigNum").css("background-color"),
        dashufc:$(".bigNum").css("color"),
        qianchongbg:$(".theFormer").css("background-color"),
        qianchongfc:$(".theFormer").css("color"),
        qianchonglianxianbg:$(".theFormerLine").css("background-color"),
        qianchonglianxianfc:$(".theFormerLine").css("color"),
        chonghaolianxianbg:$(".heavyNumberLine").css("background-color"),
        chonghaolianxianfc:$(".heavyNumberLine").css("color"),
        qiansanzufenbubg:$(".threeGroupsDis").css("background-color"),
        qiansanzufenbufc:$(".threeGroupsDis").css("color"),
        kuadubg:$(".spanDataTable").css("background-color"),
        kuadufc:$(".spanDataTable").css("color"),
        kuadulianxianbg:$(".spanDataTableLine").css("background-color"),
        kuadulianxianfc:$(".spanDataTableLine").css("color"),
        qiankuabg:$(".beforeCross").css("background-color"),
        qiankuafc:$(".beforeCross").css("color"),
        qiankualianxianbg:$(".beforeCrossLine").css("background-color"),
        qiankualianxianfc:$(".beforeCrossLine").css("color")
    }

};

function ajaxFunction(){
    //获取往期数据
    $.ajax({
        type: 'POST',
        url: "http://zcai.cn/getLotteryNum",
        data: {
            type:6,
            limit:limit1
        },
        async:false,
        success: function (res) {
            obj = res.data.reverse();
            testObj = res.data;
        },
        error:function (err) {
            console.log(err);
        }
    });
}
function getRecommend() {
    //二码 三码 四码推荐
    $.ajax({
        type: 'POST',
        url: "http://zcai.cn/getRecommend",
        data: {
            type:6
        },
        async:false,
        success: function (res) {
            recommend = res.data;
            recommendTwo = res.data;
        },
        error:function (err) {
            console.log(err);
        }
    });
}
function getMissing() {
    //遗漏统计
    $.ajax({
        type: 'POST',
        url: "http://zcai.cn/getMissing",
        data: {
            type:6
        },
        async:false,
        success: function (res) {
            missObj = res.data;
            missObjTwo = res.data;
        },
        error:function (err) {
            console.log(err);
        }
    });
}
function getLottTime(){
    //获取彩票开奖时间
    $.ajax({
        type: 'POST',
        url: "http://zcai.cn//getLotteryTime",
        data: {
            type:6
        },
        async:false,
        success: function (res) {
            lotteryTime = res.data;
            if(res.msg == 2){
                lotteryTime.text = "暂未开售";
            }
        },
        error:function (err) {
            console.log(err);
        }
    });
}
function getGameInfo(){
    //获取彩票开奖时间
    $.ajax({
        type: 'GET',
        url: "http://zcai.cn/getGameInfo",
        data:{
            type:6
        },
        async:true,
        success: function (res) {
            if(res.msg == 1){
                $(".headerLeft .spanQq").text("QQ:"+res.data[0].代理QQ);
                $(".headerLeft .spanTel").text("Tel:"+res.data[0].代理Tel);
            }
        },
        error:function (err) {
            console.log(err);
        }
    });
}










